Advertisement
Guest User

I did stuff

a guest
Apr 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using System.Numerics;
  8.  
  9.  
  10. namespace CSharpTutA.cs
  11. {
  12.  
  13. class Program
  14. {
  15.  
  16. static void Main(string[] args)
  17. {
  18.  
  19. Console.WriteLine("Hello World");
  20.  
  21. for (int i = 0; i < args.Length; i++)
  22. {
  23. Console.WriteLine("Arg {0} : {1}", i, args[i]);
  24. }
  25.  
  26. string[] myArgs = Environment.GetCommandLineArgs();
  27.  
  28. Console.WriteLine(string.Join(", ", myArgs));
  29.  
  30. bool canIVote = true;
  31.  
  32. Console.WriteLine("Biggest Integer : {0}", int.MaxValue);
  33. Console.WriteLine("Smallest Integer : {0}", int.MinValue);
  34.  
  35. Console.WriteLine("Biggest Long : {0}", long.MaxValue);
  36. Console.WriteLine("Smallest Long : {0}", long.MinValue);
  37.  
  38. decimal decPiVal = 3.1415926535897932384626433832M;
  39. decimal decBigNum = 3.00000000000000000000000000011M;
  40. Console.WriteLine("DEC : PI + bigNum = {0}", decPiVal + decBigNum);
  41.  
  42. Console.WriteLine("Biggest Decimal : {0}", Decimal.MaxValue);
  43.  
  44. Console.WriteLine("Biggest Double : {0}", Double.MaxValue.ToString("#"));
  45.  
  46. double dblPiVal = 3.14159265358979;
  47. double dblBigNum = 3.00000000000002;
  48. Console.WriteLine("DBL : PI + bigNum = {0}", dblPiVal + dblBigNum);
  49.  
  50. Console.WriteLine("Biggest Float : {0}", float.MaxValue.ToString("#"));
  51.  
  52. float fltPiVal = 3.141592F;
  53. float fltBigNum = 3.000002F;
  54. Console.WriteLine("FLT : PI + bigNum = {0}", fltPiVal + fltBigNum);
  55.  
  56. bool boolFromStr = bool.Parse("True");
  57. int intFromStr = int.Parse("100");
  58. double dblFromStr = double.Parse("1.234");
  59.  
  60. DateTime awesomeDate = new DateTime(1974, 12, 21);
  61. Console.WriteLine("Day of Week : {0}", awesomeDate.DayOfWeek);
  62.  
  63. awesomeDate = awesomeDate.AddDays(4);
  64. awesomeDate = awesomeDate.AddMonths(1);
  65. awesomeDate = awesomeDate.AddYears(1);
  66. Console.WriteLine("New Date : {0}", awesomeDate.Date);
  67.  
  68. TimeSpan lunchTime = new TimeSpan(12, 30, 0);
  69.  
  70. lunchTime = lunchTime.Subtract(new TimeSpan(0, 15, 0));
  71. lunchTime = lunchTime.Add(new TimeSpan(1, 0, 0));
  72. Console.WriteLine("New Time : {0}", lunchTime.ToString());
  73.  
  74. BigInteger bigNum = BigInteger.Parse("12345123451234512345");
  75. Console.WriteLine("Big Num * 2 = {0}", bigNum * 2);
  76.  
  77. Console.WriteLine("Currency : {0:c}", 23.455);
  78.  
  79. Console.WriteLine("Pad with 0s : {0:d4}", 23);
  80.  
  81. Console.WriteLine("3 Decimals : {0:f3}", 23.4555);
  82.  
  83. Console.WriteLine("Commas : {0:n4}", 2300);
  84.  
  85. string randString = "This is a string";
  86.  
  87. Console.WriteLine("String Length : {0}", randString.Length);
  88.  
  89. Console.WriteLine("String Contains is : {0}",
  90. randString.Contains("is"));
  91.  
  92. Console.WriteLine("Index of is : {0}",
  93. randString.IndexOf("is"));
  94.  
  95. Console.WriteLine("Remove string : {0}",
  96. randString.Remove(10, 6));
  97.  
  98. Console.WriteLine("Insert String : {0}",
  99. randString.Insert(10, "short "));
  100.  
  101. Console.WriteLine("Replace String : {0}",
  102. randString.Replace("string", "sentence"));
  103.  
  104. Console.WriteLine("Compare A to B : {0}",
  105. String.Compare("A", "B", StringComparison.OrdinalIgnoreCase));
  106.  
  107.  
  108. Console.WriteLine("A = a : {0}",
  109. String.Equals("A", "a", StringComparison.OrdinalIgnoreCase));
  110.  
  111. Console.WriteLine("Pad Left : {0}",
  112. randString.PadLeft(20, '.'));
  113.  
  114. Console.WriteLine("Pad Right : {0} Stuff",
  115. randString.PadRight(20, '.'));
  116.  
  117. Console.WriteLine("Trim : {0}",
  118. randString.Trim());
  119.  
  120. Console.WriteLine("Uppercase : {0}",
  121. randString.ToUpper());
  122.  
  123. Console.WriteLine("Lowercase : {0}",
  124. randString.ToLower());
  125.  
  126. string newString = String.Format("{0} saw a {1} {2} in the {3}",
  127. "Paul", "rabbit", "eating", "field");
  128.  
  129. Console.Write(newString + "\n");
  130.  
  131. Console.Write(@"Exactly What I Typed");
  132.  
  133. Console.ReadLine();
  134.  
  135. }
  136.  
  137. private static void SayHello()
  138. {
  139.  
  140. string name = "";
  141.  
  142. Console.Write("What is your name : ");
  143.  
  144. name = Console.ReadLine();
  145.  
  146. Console.WriteLine("Hello {0}", name);
  147. }
  148.  
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement