mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-12 17:18:40 +00:00
Implement Castclass
This commit is contained in:
18
WoofWare.PawPrint.Test/sourcesPure/CastClassToObject.cs
Normal file
18
WoofWare.PawPrint.Test/sourcesPure/CastClassToObject.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
public class Program
|
||||
{
|
||||
public class CustomClass
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
CustomClass custom = new CustomClass { Id = 42 };
|
||||
|
||||
// Everything can be cast to System.Object
|
||||
System.Object obj = (System.Object)custom;
|
||||
|
||||
// Verify it's the same object
|
||||
return obj != null && obj == custom ? 42 : 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user