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 selector c#?
Explain dataadapter.update method in .net?
What is the purpose of a constructor in c#?
Explain about c# language.
How many aware interfaces are there?
When would you use generics in your code c#?
Difference between Value type & reference types ? and give the example in .Net?
What is the real use of interface in c#?
How many constructors can a class have c#?
What is the usage of OLE?
How do you use nullable?
Write down the c# syntax to catch an exception
In dynamic link library, which api is used for load library?
What is the implicit name of the parameter that gets passed into the set method/property of a class?
What is the difference between protected and internal in c#?