Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The code would be like:
C#
string Acc_ID;

//[0] is the ID whereas the [2] is the Account type(Admin, User, etc.)
Acct_ID = rdr.GetInt32[0] + " " + rdr.GetString[2];
lblID.Text = Acc_ID;

Should I make it just like that or use Cast on them to make it execute faster? Thank you whoever can help! Sorry if it sounds annoying I'm just new to C#.

What I have tried:

Here is what I tried: rdr.GetInt32[0], rdr.GetInt32[0].ToString(), Convert.ToString(rdr.GetInt32[0]), and (int)rdr.GetInt32[0].
Posted
Updated 17-Jan-17 22:10pm
v2

1 solution

You do not need to cast, .GetInt32 returns an 32 bit integer, .String returns a string.

The only cast you need is the one to convert the int to a string if you need it as a string.

Acct_ID = rdr.GetInt32[0].ToString + " " + rdr.GetString[2];
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900