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 writeline in c#?
What is bit in c#?
What is helper method in c#?
Can arraylist hold primitive types?
Can a child class call the constructor of a base class?
How to Install uninstall assemblies into GAC?
What is a partial class. Give an example?
What is an interface class? Give one example of it
Why can't we use a static class instead of singleton?
What is ioc containers c#?
What is array formula?
Explain circular reference in c#?
how to sort an array in c#
Explain the difference between access specifier and access modifier in c#?
Why do we use interface in c#?