Comparing Variables

  • myString = "Thank God It‘s Monday" [sets the value of a string]
  • myBoolean = myString.Equals("Monday") [checks whether string equals provided input; returns: False]
  • myBoolean = myString.Contains("Monday") [checks whether string contains provided input; returns: True]
  • myBoolean = myString.StartsWith("Monday") [checks whether string starts with provided input; returns: False]
  • myBoolean = myString.EndsWith("Monday") [checks whether string ends with provided input; returns: True]
  • myInteger = DateTime.Compare(t1, t2) [returns –1 if t1 is earlier than t2, returns 0 if t1 is the same as t2 and returns 1 if t1 is later than t2]
Was this article helpful?
0 out of 0 found this helpful