Posts

Showing posts with the label C#

Cannot load Counter Name data because an invalid index '' was read from the registry

If you are unable to get the performance metrics of a machine: Running this command from command prompt may help: lodctr /r Check if all are enabled: lodctr /q

C# - Reference Example

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace reference { class Program { static void Main(string[] args) { int i = 5; Method(ref i); Console.WriteLine(i.ToString()); Console.ReadLine(); } static void Method(ref int j) { j = j + 7; } } }

Factorial using Recursion C#

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Factorial { class Program { static void Main(string[] args) { Console.WriteLine(factorial(4)); Console.ReadLine(); } static int factorial(int n) { if (n > 1) { return factorial(n - 1) * n; } else { return 1; } } } }