How to use properties?

Beginner

Member
Joined
May 31, 2018
Messages
5
Programming Experience
Beginner
How Can I retrieve data through a proprerty in c sharp??




---> This method is contained in my main :


C#:
static decimal RetrievePower(SDK.Event.ResultEventArgs e)
{

//Here I want retrieve The data of the properties

}




Look at inside the SDK.Event.ResultEventArgs class:
C#:
namespace Sun.SDK.Event
{
public sealed class ResultEventArgs : EventArgs
{
public ResultEventArgs(string id, string shop, IList<ResultEntity> result, OperationCode code, object extdata = null);


public string StationID { get; set; }
public string ShopCode { get; set; }
public object ExtData { get; set; }
public IList<ResultEntity> ResultList { get; } 
//--->I don't know how I have to manage the property public IList<ResultEntity> ResultList { get; } 
public OperationCode OptCode { get; set; }
}
}



Look at inside ClassResultEntity

C#:
namespace Sun.SDK.Entity
{
public sealed class ResultEntity
{
public ResultEntity();


public string StationID { get; set; }
public string TagID { get; set; }
public TagStatus TagStatus { get; set; }
public int Signal { get; set; }
public int Temperature { get; set; }
public int Version { get; set; }
public Power PowerLevel { get; set; } 
// PowerLevel is the parameter I have to retrieve, but I don't know how..
public decimal PowerValue { get; set; }
public string BatchCode { get; set; }
public int FuncKeyStatus { get; set; }
public ResultType ResultType { get; set; }
}
}





Ho can I retrieve power Level from public sealed class ResultEntity and import its in my main class?
 
I think this should be it, see if this helps:
foreach (var result in e.ResultList) {
   var level = result.PowerLevel;

}
 
C# Properties:
class Student
{
     private int history;

        public int _history
        {
            get { return history; }
            set {
                if (HistValidation(value))
                    history = value;               
                else
                    throw new Exception("Invalid History Marks");

            }
        }
        private bool HistValidation(int history)
        {
            if (history > 0 && history <= 100)
                return true;
            return false;
        }
    
}

class Abc
{
    public static void main(string[] args)
    {
        Student s=new Student();
        s._history=35;
    }
    
}
 
Back
Top Bottom