-1

I am new to c# and mvc. I am using mvc. In view model, I have two property; one of them is public int MaxCapacity { get; set; } and the other one is public int UsedCapacity { get; set; } I want to use them and show UsedCapacity/MaxCapacity in the column but I don't know how to combine them. I want to cretae new property and write get set methods using MaxCapacity and UsedCapacity ;

public int Capacity
        {
            get
            {

            }
            set
            {

            }

        }

1 Answer 1

1
public int Capacity
    {
        get
        {
            return this.UsedCapacity/this.MaxCapacity;
        }
        set
        {
            if(value > MaxCapacity)
               throw new Exception("Can't set capacity bigger then max capacity");
            // Your code...
        }

    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.