# Int32

***

1. **Store a numerical value:**

```c#
int num = 12345;
```

2. **Perform arithmetic operations:**

```c#
int result = 10 + 20;   // result = 30
```

3. **Compare values:**

```c#
if (a == b) { /* ... */ }
if (a > b) { /* ... */ }
```

4. **Increment or decrement a value:**

```c#
int counter = 0;
counter++;   // counter = 1
counter--;   // counter = 0
```

5. **Use in mathematical functions:**

```c#
double sqrtResult = Math.Sqrt(16);   // sqrtResult = 4
```

6. **Use in array indexing:**

```c#
int[] numbers = new int[10];
numbers[0] = 1;
```

7. **Use in loops:**

```c#
for (int i = 0; i < 10; i++) { /* ... */ }
```

8. **Represent bitwise operations:**

```c#
int flags = 0x0F;   // represents 15 bits set
```

9. **Represent binary, octal, or hexadecimal values:**

```c#
int binaryValue = 0b1010;   // binary 1010
int octalValue = 0777;   // octal 777
int hexValue = 0xABC;   // hexadecimal ABC
```

10. **Use in custom data structures:**

```c#
public class Node<T>
{
    public T Value { get; set; }
    public Node<T> Next { get; set; }
    public int Count { get; set; } // Int32 field
}
```

11. **Represent color values in RGB:**

```c#
int red = 255;
int green = 128;
int blue = 0;
```

12. **Represent dates and times as timestamps:**

```c#
int timestamp = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
```

13. **Store the length of a string:**

```c#
string text = "Hello World!";
int textLength = text.Length;
```

14. **Represent the number of elements in a collection:**

```c#
List<string> names = new List<string>();
int count = names.Count;
```

15. **Store the position of an item in a collection:**

```c#
List<int> numbers = new List<int>();
int index = numbers.IndexOf(10);
```

16. **Use in LINQ queries:**

```c#
var result = numbers.Where(n => n % 2 == 0);
```

17. **Store file sizes:**

```c#
FileInfo fi = new FileInfo("myfile.txt");
long fileSize = fi.Length;
```

18. **Represent the memory address of a variable:**

```c#
int x = 10;
int* address = &x;
```

19. **Use in bit manipulation:**

```c#
int flags = 0x0F;
int result = flags & 0x07; // clears the upper 4 bits
```

20. **Represent user input:**

```c#
Console.WriteLine("Enter a number:");
int input = Convert.ToInt32(Console.ReadLine());
```

21. **Store the number of rows in a database table:**

```c#
int rowCount = db.ExecuteScalar("SELECT COUNT(*) FROM MyTable");
```

22. **Represent the number of threads in a thread pool:**

```c#
int minThreads = 1;
int maxThreads = Environment.ProcessorCount;
```

23. **Store the index of a selected item in a list box:**

```c#
int selectedIndex = myListBox.SelectedIndex;
```

24. **Represent the zoom level of a map:**

```c#
int zoomLevel = 15;
```

25. **Store the number of pixels in an image:**

```c#
int width = image.Width;
int height = image.Height;
```

26. **Represent the number of files in a directory:**

```c#
int numFiles = Directory.GetFiles("myDirectory").Length;
```

27. **Store the number of subkeys in a registry key:**

```c#
int numSubKeys = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default).GetSubKeyNames().Length;
```

28. **Represent the number of bytes sent or received over a network:**

```c#
int bytesSent = socket.Send(buffer);
int bytesReceived = socket.Receive(buffer);
```

29. **Store the ID of a database record:**

```c#
int recordId = db.ExecuteScalar("SELECT ID FROM MyTable WHERE Name = 'John Doe'");
```

30. **Represent the number of characters in a text box:**

```c#
int charCount = myTextBox.TextLength;
```

31. **Store the position of a cursor in a text editor:**

```c#
int cursorPosition = myTextBox.SelectionStart;
```

32. **Represent the number of lines in a text file:**

```c#
int lineCount = File.ReadAllLines("myFile.txt").Length;
```

33. **Store the number of items in a menu:**

```c#
int menuItemCount = myMenu.Items.Count;
```

34. **Represent the number of columns in a data grid:**

```c#
int columnCount = myDataGrid.Columns.Count;
```

35. **Store the number of nodes in a tree view:**

```c#
int nodeCount = myTreeView.Nodes.Count;
```

36. **Represent the number of items in a queue:**

```c#
int queueSize = myQueue.Count;
```

37. **Store the number of items in a stack:**

```c#
int stackSize = myStack.Count;
```

38. **Represent the number of items in a hash table:**

```c#
int hashTableCount = myHashTable.Count;
```

39. **Store the number of items in a linked list:**

```c#
int linkedListCount = myLinkedList.Count;
```

40. **Represent the number of bytes in a memory stream:**

```c#
int memoryStreamSize = myMemoryStream.Length;
```

41. **Store the number of items in an array:**

```c#
int arraySize = myArray.Length;
```

42. **Represent the number of members in a type:**

```c#
int typeMemberCount = typeof(MyClass).GetMembers().Length;
```

43. **Store the number of methods in a type:**

```c#
int typeMethodCount = typeof(MyClass).GetMethods().Length;
```

44. **Represent the number of properties in a type:**

```c#
int typePropertyCount = typeof(MyClass).GetProperties().Length;
```

45. **Store the number of fields in a type:**

```c#
int typeFieldCount = typeof(MyClass).GetFields().Length;
```

46. **Represent the number of events in a type:**

```c#
int typeEventCount = typeof(MyClass).GetEvents().Length;
```

47. **Store the number of interfaces implemented by a type:**

```c#
int typeInterfaceCount = typeof(MyClass).GetInterfaces().Length;
```

48. **Represent the number of attributes applied to a type:**

```c#
int typeAttributeCount = typeof(MyClass).GetCustomAttributes().Length;
```

49. **Store the number of parameters in a method:**

```c#
int methodParameterCount = typeof(MyClass).GetMethod("MyMethod").GetParameters().Length;
```

50. **Represent the number of overloadings of a method:**

```c#
int methodOverloadCount = typeof(MyClass).GetMethods().Where(m => m.Name == "MyMethod").Count();
```
