Zdravim ,v mojom kode (skusam jednoduche OOP) som mal problem s tým,že ked som mal "public ...carDetails" tak to neslo ale ked som dal private tak to slo,akurat ze neviem prečo :) Ďakujem
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Car myNewCar = new Car();
myNewCar.Year = 1950;
myNewCar.Model = "BMW";
myNewCar.Color = "Black";
myNewCar.Value = 42000;
carDetails(myNewCar);
Console.ReadKey();
}
private static void carDetails(Car _car) {
Console.WriteLine(_car.FormatMe());
}
class Car
{
public int Year { get; set; }
public string Model { get; set; }
public string Color { get; set; }
public int Value { get; set; }
public string FormatMe() {
return String.Format("{0} - {1} - {2} - {3}",
this.Color,
this.Model,
this.Value,
this.Year);
}
}
}
}