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 func c#?
Assembly Code. in Rejester AL. How do Contast Replece( or Change): Bit D3 With Bit D4 and Bit D2 With Bit D5 and Bit D1 With Bit D6 and Bit D0 With Bit D7 I am Not Know Very Well Write English.
What is the difference between properties and indexer in c#?
Define delegation in .net?
Explain what are the steps for creating clr trigger?
What is dynamic object in c#?
What is type safe code?
What is a static class in c#?
I need code to connect ohter systems in the LAN and i want to display my website image over there and i want explain as a admin through phone. So i need code to access other system using C-Sharp. Any one please help me.Please give me the code. Advace thanks.
What is the difference between serialization and deserialization in c#?
How do you create dlls in .NET
What is indexer c#?
What is the advantage of generics in c#?
Why are strings immutable c#?
What is eager and lazy loading in c#?