How to return value with this issue? Help me please.
protected string SendState(Object ID_DIP,Object ID_SEQ,Object MODUL)
{
try
{
ViewState["ssDIP"] = ID_DIP.ToString();
ViewState["ssSEQ"] = ID_SEQ.ToString();
ViewState["ssMOD"] = MODUL.ToString();
return ID_DIP.AsString();
return ID_SEQ.AsString();
return MODUL.ToString();
}
catch (Exception)
{
return "";
}
}
You have multiple return statements, your code will not execute statements after first return statement. You can't return multiple values from your method, if you want to return multiple values you can either return List<string> for your case or create a temporary class and return its object.
In your code you are using AsString, I think you probably meant ToString
Define a class like:
public class MyReturnObject
{
public string ID_DIP { get; set; }
public string ID_SEQ { get; set; }
public string MODUL { get; set; }
}
Modify your method like:
protected MyReturnObject SendState(Object ID_DIP, Object ID_SEQ, Object MODUL)
{
try
{
ViewState["ssDIP"] = ID_DIP.ToString();
ViewState["ssSEQ"] = ID_SEQ.ToString();
ViewState["ssMOD"] = MODUL.ToString();
MyReturnObject obj = new MyReturnObject();
obj.ID_DIP = ID_DIP.ToString();
obj.ID_SEQ = ID_SEQ.ToString();
obj.MODUL = MODUL.ToString();
return obj;
}
catch (Exception)
{
return null;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With