Adding values to a C# array

You can do this way – Alternatively, you can use Lists – the advantage with lists being, you don’t need to know the array size when instantiating the list. Edit: a) for loops on List<T> are a bit more than 2 times cheaper than foreach loops on List<T>, b) Looping on array is around 2 times cheaper than looping on … Read more

How to fix “namespace x already contains a definition for x” error? Happened after converting to VS2010

I had this happen to me about a year ago and I don’t remember exactly what the root cause was, but there are two things you might try: If it’s an auto-generated file (as ‘Resources.Designer.cs’ tend to be), try deleting it and letting VS re-generate it. Either separately or in conjunction with #1, select Show All … Read more

how to convert C# to C++

Actually as it is complicated to mix C# and C++ on unix, I am trying to convert C# to C++ Have you considered Mono? It is something that’s definitely worth checking before starting to learn C++ in order convert and run an existing .NET application on Unix. It’s also binary compatible meaning that you don’t even … Read more

Get dictionary value by key

It’s as simple as this: Note that if the dictionary doesn’t have a key that equals “XML_File”, that code will throw an exception. If you want to check first, you can use TryGetValue like this:

Unity 2d jumping script

Usually for jumping people use Rigidbody2D.AddForce with Forcemode.Impulse. It may seem like your object is pushed once in Y axis and it will fall down automatically due to gravity. Example:

How do I read and parse an XML file in C#?

XmlDocument to read an XML from string or from file. or then find a node below it ie like this or then read the text inside that node like this or read an attribute Always check for null on Attributes[“something”] since it will be null if the attribute does not exist.

Convert char to int in C#

Interesting answers but the docs say differently: Use the GetNumericValue methods to convert a Char object that represents a number to a numeric value type. Use Parse and TryParse to convert a character in a string into a Char object. Use ToString to convert a Char object to a String object. http://msdn.microsoft.com/en-us/library/system.char.aspx