C# Code for How to set readonly property to Id(database)
value?
Answer Posted / deepak ray
Just retrieve the id from database using reader or dataset
and store the id in a string.
and
set the string in a public readonly property like this.
string _UserId;
public string UserId
{ get { return _UserId; } }
SqlDataReader dr = null;
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
_UserId = dr["UserId"].ToString();
}
dr.Close();
dr.Dispose();
Is This Answer Correct ? | 10 Yes | 6 No |
Post New Answer View All Answers
What is the difference between // comments, /* */ comments and /// comments?
What is anonymous methods in c#?
How many types of methods are there in c#?
List out the differences between array and arraylist in c#?
What is static noise?
How many constructors can a class have in c#?
What is platform independence"?
Is and as in c#?
What is firstordefault c#?
What is anonymous types in c#?
What is difference between class and abstract class in c#?
How to rotate an Image in C#?
Can we have multiple threads in one app domain?
What is difference between array and arraylist c#?
Is c# a backend language?