C# Macro definitions in Preprocessor

No, C# does not support preprocessor macros like C. Visual Studio on the other hand has snippets. Visual Studio’s snippets are a feature of the IDE and are expanded in the editor rather than replaced in the code on compilation by a preprocessor.

Best way to “push” into C# array

array.push is like List<T>.Add. .NET arrays are fixed-size so you can’t actually add a new element. All you can do is create a new array that is one element larger than the original and then set that last element, e.g. EDIT: I’m not sure that this answer actually applies given this edit to the question: … Read more

Type Checking: typeof, GetType, or is?

All are different. typeof takes a type name (which you specify at compile time). GetType gets the runtime type of an instance. is returns true if an instance is in the inheritance tree. Example What about typeof(T)? Is it also resolved at compile time? Yes. T is always what the type of the expression is. … Read more

No overload for method ” takes 1 argument

Here, you are passing an extra argument (true) to the method GetActive. As we can see from the method declaration of GetActive, it takes no parameters: I think what you mean here is “if Player2.GetActive() is true…” right? You don’t need to specify the value you want if it is true, just doing this is … Read more

How to create a new object instance from a Type

The Activator class within the root System namespace is pretty powerful. There are a lot of overloads for passing parameters to the constructor and such. Check out the documentation at: http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx or (new path) https://docs.microsoft.com/en-us/dotnet/api/system.activator.createinstance Here are some simple examples: