Files
ProxyGenerator/tests/ProxyInterfaceSourceGeneratorTests/Source/OperatorTest.cs
T
Adam Hathcock e341772cbc add csharpier
2024-05-21 16:34:46 +01:00

41 lines
889 B
C#

namespace ProxyInterfaceSourceGeneratorTests.Source
{
public class OperatorTest
{
public string Name { get; set; } = null!;
public int? Id { get; set; }
// Operator : implicit
public static implicit operator OperatorTest(string name)
{
return new() { Name = name };
}
public static implicit operator OperatorTest(int? id)
{
return new() { Id = id };
}
// Operator : explicit
public static explicit operator string(OperatorTest test)
{
return test.Name;
}
public static explicit operator int?(OperatorTest test)
{
return test.Id;
}
}
public class X
{
public X()
{
OperatorTest operatorTest = "stef";
var s = (string)operatorTest;
}
}
}