Advertisement
karlakmkj

String - comparison

Nov 26th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StringTheException
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       string s1 = "immutable";
  10.       string s2 = "immutable";
  11.  
  12.       Console.WriteLine((s1 == s2)); //True because they are pointing to the same value "immutable"
  13.  
  14.       Object o1 = new Object();
  15.       Object o2 = new Object();
  16.  
  17.       Console.WriteLine(o1 == o2); //False because they are pointing at different objects
  18.     }
  19.   }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement