Create the enumerated list and an object Use it
Category: Memory
Arrays(3)
List(1)
MemoryStream(1)
Pointers(1)
Converting Variables
Convert Float / Single to Bytes float float1 = 1.0F; Byte[] ByteArray1 = BitConverter.GetBytes(float1); Convert Bytes to Float/Single Byte[] ByteArray1 = new Byte[4] {1,2,3,4}; float float1 = BitConverter.ToSingle(ByteArray1, 0);
static
Class static variables A static variable shares the value of it among all instances of the class. static Local Variables in C# Nope, you can't have a static local variable in a method in C#, get over it. Declare them in the class. The reason – C# is an Object Oriented programing language, C (which […]
AND, OR and binary operations on variables
C# is not the same as C or C++!!!!! Simple byte operations for example do not result in a byte result, they often result in an Int32 result An example binary operation This will generat the error “Cannot implicitly convert type ‘int’ to ‘byte’. An explicit conversion exists (are you missing a cast)”: Its because […]
Cast
"Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast)" error This will generat the error: TxData[ByteIndex++] = (byte)TagIdCharacter[0] | 0x80; Its because the result of the IOR operation does not result in a byte, so you need to use parenthesis: TxData[ByteIndex++] = (byte)(TagIdCharacter[0] | 0x80);
Constants
You have to use constants within a class. So like this: You’d need to put it in a class somewhere, and the usage would be ClassName.MY_NUMBER Number Defines String Defines Array Defines Const can’t be used because it can only be applied to a field whose value is known at compile-time and arrays are not […]
Variables
The structure below shows the various basic types of C# and the types they map to in the .Net framework. C# Short Name .Net Class Declaration Description bool Boolean bool isValid = true; 8 bit true or false sbyte SByte sbyte b = -1 signed 8 bit integer byte Byte byte b = 1; 8 bit […]