using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apps
{
class PropertiesTest
{
private string title = "Hi";
public string Title
{
get
{
return title;
}
set
{
title = value;
}
}
public int duration { get; set; }
public int fees { get; set; }
private string[] topics = new string[5];
public string this[int index] // Implementing Indexer
{
get
{
return topics[index];
}
set
{
topics[index] = value;
}
}
public void print()
{
Console.WriteLine(title);
}
public PropertiesTest(string title, int duration, int fees)
{
this.title = title;
this.duration = duration;
this.fees = fees;
print();
}
}
class UnderstandingPropertiesConcept
{
public static void Main()
{
PropertiesTest pt1 = new PropertiesTest("MS.Net", 52, 6000);
pt1.Title = "Hello";
Console.WriteLine(pt1.Title);
PropertiesTest pt = new PropertiesTest("MS.Net", 52, 6000);
Console.WriteLine(pt.Title);
pt[0] = "Indexer Concept";
pt[1] = "Indexer Concept";
//foreach (string n in pt[])
//{
// n = "indexer concept";
//}
}
}
}
No comments:
Post a Comment