Function to check for null and change to string?


let's have this. if strname null strvar end being null:

string strvar = "hello " + strname;

is there predefined function check if it's null , replace valid string? example:

string strvar = "hello, " + isnull(strname, "i have no name"); //result: hello, have no name

thanks.

you can check before add strvar, using this

if(!string.isnullorempty(strname)) {   // u need }

or can make ternary if after add strvar one

            string strname = ""; // empty value string             strname = strname.equals("") ? "i have no name" : strname;
string strvar = "hello " + strname;


web developer





Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to Share webservice object to all user