TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Doğukan Gözen
NA
5
595
list and two classes
Apr 7 2019 5:29 PM
public class A
{
public int x;
public int y;
public A(int x, int y)
{
this.x = x;
this.y = y;
}
public int Make()
{
return 1;
}
}
public class B : A
{
public int z;
public B(int x, int y, int z) : base(x, y)
{
this.z = z;
}
public int Make()
{
return 1;
}
}
class Program
{
static void Main(string[] args)
{
List<A> myA = new List<A>();
myA.Add(new A(1, 2));
myA.Add(new B(3, 4, 5));
Console.WriteLine(myA[0].Make());
Console.WriteLine(((B)myA[1]).Make());
for(int i = 0; i < 2; i++)
{
Console.WriteLine(myA[i].Make()); //how to send classB.make this element.
}
Reply
Answers (
1
)
how to store 2d array value using loops in c#
How to pick the corresponding value of the key in the Dictio