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 does console readline do?
What is the default value of datetime in c#?
Can we change static value in c#?
Write a short note on interface?
What is a console?
What is the difference between yield and return?
How do I do a case-insensitive string comparison?
What is a Managed Code??
What is var c#?
What is private class in c#?
What is the difference between dictionary and hashtable in c#?
What is an enumerator c#?
Define c# i/o classes?
How to override a function in c#?
Why c# is called c sharp?