Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting unit to string 1

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
Is there a way to return a blank value for uint datatype?

Also can I convert uint to String or vice versa?

Thank you
 
For a "blank" value, you can use the Uint32 class and return null.

Just use the ToString() method of Uint32 or uint to convert to a string.

To convert back to a uint, use Uint32.Parse()
 
Sorry, UInt32 is a struct (C# != Java, I got confused). You need to use the Nullable<uint> type, and this can be null.
 
Sorry for the spamming, but I just remembered the good syntax for this. Declare the variable as

uint? x;

Then you can do things like

x = null;
x = 32;
 
I have a function whose return type is uint, if there is no value returned it returns null, using the same concept as you mentioned in the previous post.

Now, how can the calling function check if the value returnd is null or empty?

thank you
 
You're using null as a special value to indicate no-value, so you can't tell the difference. Another way of thinking about it is that no-value and empty are equivalent.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top