Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
QuestionRunning SQL Server 2008 R2 without user interaction Pin
WaseemAmin11-Sep-13 21:49
WaseemAmin11-Sep-13 21:49 
AnswerRe: Running SQL Server 2008 R2 without user interaction Pin
Richard MacCutchan11-Sep-13 22:26
mveRichard MacCutchan11-Sep-13 22:26 
GeneralRe: Running SQL Server 2008 R2 without user interaction Pin
WaseemAmin12-Sep-13 5:54
WaseemAmin12-Sep-13 5:54 
AnswerRe: Running SQL Server 2008 R2 without user interaction Pin
PIEBALDconsult12-Sep-13 3:03
mvePIEBALDconsult12-Sep-13 3:03 
GeneralRe: Running SQL Server 2008 R2 without user interaction Pin
WaseemAmin12-Sep-13 6:02
WaseemAmin12-Sep-13 6:02 
GeneralRe: Running SQL Server 2008 R2 without user interaction Pin
PIEBALDconsult12-Sep-13 14:11
mvePIEBALDconsult12-Sep-13 14:11 
Generalreadonly keyword Pin
N8tiv11-Sep-13 20:38
N8tiv11-Sep-13 20:38 
GeneralRe: readonly keyword Pin
Pete O'Hanlon11-Sep-13 21:05
mvePete O'Hanlon11-Sep-13 21:05 
There's a subtle difference between readonly and const which it sort of emulates. If you like, you can think of readonly as a runtime constant as opposed to const which is a compile time constant. What does this mean? Well, a readonly field can be set in a constructor, so the value that is held in the readonly field is made constant once the class is initialised, as opposed to const where it's constant from the start. In other words, you can change the value in a readonly field at runtime, but you can't with a const field. A practical example might help. The first class defines the ANSWER, which can never change.
C#
public class H2G2
{
  private const int Answer = 42;
  public H2G2()
  {
    Console.WriteLine("The answer to Life, the Universe, Everything is {0}", Answer);
  }
}
A couple of things to notice in this example. The first is that you can't change the value of Answer while the application is running. The second thing (unsaid), is that you can't make the const static. Okay, now here's a version of readonly.
C#
public class TaxCalc
{
  private readonly double taxRate;
  public TaxCalc(double taxRate)
  {
    this.taxRate = taxRate;
  }

  public void Calculate(double value)
  {
    double total = value * taxRate; // Note that taxRate cannot change now that it has been set.
      // this means you can't do something like this --taxRate;
    Console.WriteLine("The total is {0}", total);
  }
}


GeneralRe: readonly keyword Pin
N8tiv11-Sep-13 21:18
N8tiv11-Sep-13 21:18 
GeneralRe: readonly keyword Pin
Pete O'Hanlon11-Sep-13 22:58
mvePete O'Hanlon11-Sep-13 22:58 
GeneralRe: readonly keyword Pin
N8tiv11-Sep-13 23:12
N8tiv11-Sep-13 23:12 
GeneralRe: readonly keyword Pin
Abhinav S12-Sep-13 8:22
Abhinav S12-Sep-13 8:22 
GeneralRe: readonly keyword Pin
DaveyM6913-Sep-13 9:40
professionalDaveyM6913-Sep-13 9:40 
Questiondelay and back again record Pin
eng.iris11-Sep-13 18:07
eng.iris11-Sep-13 18:07 
AnswerRe: delay and back again record Pin
Eddy Vluggen12-Sep-13 2:58
professionalEddy Vluggen12-Sep-13 2:58 
GeneralRe: delay and back again record Pin
eng.iris12-Sep-13 8:21
eng.iris12-Sep-13 8:21 
GeneralRe: delay and back again record Pin
Eddy Vluggen12-Sep-13 10:42
professionalEddy Vluggen12-Sep-13 10:42 
GeneralRe: delay and back again record Pin
Eddy Vluggen13-Sep-13 7:06
professionalEddy Vluggen13-Sep-13 7:06 
Questiontv show control in c# Pin
eng.iris11-Sep-13 17:54
eng.iris11-Sep-13 17:54 
AnswerRe: tv show control in c# Pin
Abhinav S11-Sep-13 18:24
Abhinav S11-Sep-13 18:24 
General"this" keyword Pin
N8tiv11-Sep-13 17:17
N8tiv11-Sep-13 17:17 
GeneralRe: "this" keyword Pin
Ron Beyer11-Sep-13 17:35
professionalRon Beyer11-Sep-13 17:35 
GeneralRe: "this" keyword Pin
N8tiv11-Sep-13 18:08
N8tiv11-Sep-13 18:08 
GeneralRe: "this" keyword Pin
Ron Beyer11-Sep-13 18:15
professionalRon Beyer11-Sep-13 18:15 
GeneralRe: "this" keyword Pin
N8tiv11-Sep-13 18:26
N8tiv11-Sep-13 18:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.