Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
public const string FILE_NAME
="example.bin" ; static void Main ( ){
FileStream fs= new FileStream(FILE_NAME,FileMode
. CreateNew) // Create the writer for data .
;BinaryWriter w=new BinaryWriter ( fs );
// Write data to Test.data.
for( int i=0;i<11;i++){w.Write((int)i);}w .Close();
fs . Close ( ) // Create the reader for data.
;fs=new FileStream(FILE_NAME,FileMode. Open
, FileAccess.Read) ;BinaryReader r
= new BinaryReader(fs); // Read data from Test.data.
for (int i = 0; i < 11; i++){ Console .WriteLine
(r.ReadInt32 ())
;}r . Close ( ); fs . Close ( ) ; }
if (some condition)
{
// Block contents indented by a single [Tab]
// VS will replace the [Tab] with 4 spaces
}
if (some condition) {
// Block contents indented by a single [Tab]
// Choosing between [tab] and spaces depends
// on project formatting style
}
// swap left and right elements for whole array
for (var i = 0; i < MaxElements; i++)
{
leftElement = left[i];
left[i] = right[i];
right[i] = leftElement;
}
// swap left and right elements for whole array
for ( var i=0; i<MaxElements; i++ )
leftElement = left[i];
left[i] = right[i];
right[i] = leftElement;
x = 3+4 * 2+7;
x = (3 + 4) * (2 + 7);
public class Factorial
{
private static ulong CalcFactorial(uint num)
{
if (num == 0)
{
return 1;
}
else
{
return num * CalcFactorial(num - 1);
}
}
static void Main()
{
ulong factorial = CalcFactorial(5);
Console.WriteLine(factorial);
}
}
public class Indentation_Example_
{
private int Zero()
{
return 0;
}
}
private static ulong CalcFactorial(uint num)
private static ulong CalcFactorial ( uint num )
private static ulong CalcFactorial (uint num)
if (condition) { … }
for (int i = 0; i < 10; i++) { … }
private void RegisterUser(string username, string password);
RegisterUser("academy", "s3cr3t!p@ssw0rd");
private void RegisterUser(string username,string password)
private void RegisterUser(string username ,string password)
private void RegisterUser(string username , string password)
private List<Report> PrepareReports()
{
List<Report> reports = new List<Report>();
// Create incomes reports
Report incomesSalesReport = PrepareIncomesSalesReport();
Report incomesSupportReport = PrepareIncomesSupportReport();
reports.Add(incomesSalesReport, incomesSupportReport);
// Create expenses reports
Report expensesPayrollReport = PrepareExpensesPayrollReport();
Report expensesMarketingReport = PrepareExpensesMarketingReport();
reports.Add(expensesPayrollReport, expensesMarketingReport);
return reports;
}
public class Dog
{
// Static variables
public const string SPECIES = "Canis Lupus Familiaris";
// Instance variables
private int age;
// Constructors
public Dog(string name, int age)
{
this.Name = name;
this.Аge = age;
}
// Properties
public string Name { get; set; }
// Methods
public void Breath()
{
// TODO: breathing process
}
public void Bark()
{
Console.WriteLine("wow-wow");
}
}
for (int i = 0; i < 10; i++)
{
Console.WriteLine("i={0}", i);
}
for (int i = 0; i < 10; i++)
Console.WriteLine("i={0}", i);
for (int i = 0; i < 10; i++) Console.WriteLine("i={0}", i);
for (int i = 0; i < 10;) {
Console.WriteLine("i={0}", i); i++; Console.WriteLine();
}
public static void PrintList(List<int> ints)
{
Console.Write("{ ");
foreach (int item in ints)
{
Console.Write(item);
Console.Write(" ");
}
Console.WriteLine("}");
}
static void Main()
{
// …
for (int i = 0; i < 10;)
{
Console.WriteLine("i={0}", i);
i++;
Console.WriteLine();
}
if (matrix[x, y] == 0 || matrix[x-1, y] == 0 ||
matrix[x+1, y] == 0 || matrix[x, y-1] == 0 ||
matrix[x, y+1] == 0)
{ …
public void GetAllAbstractPaintings()
{
var paintings = this.Database.Paintings.All()
.Where(x => x.PaintingStyle == PaintingStyleType.Abstract)
.OrderBy(x => x.Price)
.ThenBy(x => x.DateCreated)
.Select(x => x.OriginalPaintingPath)
.ToList();
}
if (matrix[x, y] == 0 || matrix[x-1, y] ==
0 || matrix[x+1, y] == 0 || matrix[x,
y-1] == 0 || matrix[x, y+1] == 0)
{ …
if (matrix[x, y] == 0 || matrix[x-1, y] == 0 ||
matrix[x+1, y] == 0 || matrix[x, y-1] == 0 ||
matrix[x, y+1] == 0)
{ …
DictionaryEntry<K, V> newEntry
= new DictionaryEntry<K, V>(oldEntry
.Key, oldEntry.Value);
if (matrix[x, y] == 0 || matrix[x-1, y] == 0 ||
matrix[x+1, y] == 0 || matrix[x, y-1] == 0 ||
matrix[x, y+1] == 0)
{
matrix[x, y] == 1;
}
if (matrix[x, y] == 0 || matrix[x-1, y] == 0 ||
matrix[x+1, y] == 0 || matrix[x, y-1] == 0 ||
matrix[x, y+1] == 0) {
matrix[x, y] == 1;
}
public void NotCool()
{
var student = new Student("Ivan", "Kolev", 21);
var studentGrades = new List<int>() { 2, 3, 4, 5, 6 };
var school = new SMG("Kopernik");
var studenstInSchool = new List<Student>();
}