I am learning C# and I would like to know what is the use of a field in a C# class?
example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Class_Constructor_II
{
class Fields
{
const double RandsInADollar = 7.8;
const double RandsInAEuro = 10.83
public double RandDollarConversion
{
get
{
return RandsInADollar / DollarRands;
}
set
{
DollarRands = value / RandsInADollar;
}
}
public double DollarRands
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
Fields f = new Fields();
f.DollarRands = 14500000;
Console.WriteLine(f.DollarRands);
}
}
}
Nothing better than the MSDN Definition:
MSDN – Fields
In case Microsoft decides to change their MSDN URLs again, here it is: