Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# different getter setter types

public class TDecimal
{
    private decimal? m_value;
    public bool HasValue { get { return m_value.HasValue; } }
    public decimal Value { get { return m_value.Value; } }

    public static implicit operator TDecimal(string a_value)
    {
        decimal d;
        if (decimal.TryParse(a_value, out d))
        {
            return new TDecimal() {m_value = d};
        }

        return new TDecimal() {m_value = null};
    }

    public static implicit operator decimal(TDecimal a_value)
    {
        if(a_value.HasValue)
        {
            return a_value.Value;
        }

        throw new ArgumentNullException("a_value");
    }
}

public class A
{
    public TDecimal Prop { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: wpf button to return to last window 
Csharp :: populate array from an XML file 
Csharp :: erewt 
Csharp :: scale min max to 0 1 
Csharp :: pass viewbag selectlistitem to razor 
Csharp :: infinit range loop c# 
Csharp :: c# Least prime factor of numbers till n 
Csharp :: DisplayUnitType revit api 
Csharp :: camera is rendering black screen unity 
Csharp :: how to assign 2d physics material through script 
Csharp :: dictionary plus generic class c# 
Csharp :: tune off exit button wpf 
Csharp :: how to extract data from a document using c# 
Csharp :: wpf ope another project page 
Csharp :: angular === vs == 
Csharp :: c# bitwise and 
Csharp :: redsymbol.net exit traps 
Csharp :: hur delar man upp en e post på string c# 
Csharp :: f# print array strings 
Csharp :: read text c# 
Csharp :: dateTime to dataRow in c# 
Csharp :: salary, overtime, deductions, gross pay and netpay in console C# 
Csharp :: c# check if pdf is protected without password 
Csharp :: TextBox filling in C# 
Csharp :: C# declare object with values 
Csharp :: ef core save keyless entity 
Csharp :: loops in coding 
Csharp :: isselected uicollectionview reused 
Csharp :: how to unfocus a richtextbox windows forms 
Csharp :: reflection static method c# 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =