pszczyg

EnumSpeed_02

Sep 14th, 2021
1,503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1.         [Test]
  2.         public void Enum_Casting_And_Comparison()
  3.         {
  4.             var castFromExisting = (InvoicePaymentMethod)'A'; //result: AutoGiroNorway            
  5.             var castFromNotExisting = (InvoicePaymentMethod)'Ż'; //result: 379 - (int)'Ż'
  6.  
  7.             var comparisonWithExisting = (InvoicePaymentMethod)'\0' == InvoicePaymentMethod.Undefined; //true
  8.             var comparisonWithNotExisting = (InvoicePaymentMethod)'Ż' == InvoicePaymentMethod.Undefined; //false            
  9.         }
Advertisement
Add Comment
Please, Sign In to add comment