foreach(int i in Enumerable.Range(min_number, max_number)) { Console.WriteLine(i); }
String to int
Convert.ToInt32(string)
Reading a text file
StreamReader sr = new StreamReader(file_path); string data = sr.ReadLine(); sr.Close();
Checking for whole number
if((someValue % 1) == 0) { Console.WriteLine("someValue is a whole number"); }
Create random int
Random random = new Random(); int randInt = random.Next(min, max);Generate md5 hash from string
string GetMd5Hash(string inputString) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] byteString = Encoding.UTF8.GetBytes(inputString); byteString = md5.ComputeHash(byteString); StringBuilder stringBuilder = new StringBuilder(); foreach(byte b in byteString) { stringBuilder.Append(b.ToString("x2").ToLower()); } string hashString = stringBuilder.ToString(); return hashString;
}
No comments:
Post a Comment