//interface and c# Using Values Add
interface add
{
int add(int a, int b);
}
class adds : add
{
public int c;
public int add(int a, int b)
{
c = a + b;
return c;
}
}
///default.cs
adds c1 = new adds();
add val_add = new adds();
val_add.add(15, 15);
Response.Write(c1.c);
8 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Akhil GargPosted Aug 7, 2015, 9:43 PM
yuvaraj kPosted Aug 7, 2015, 7:35 AM
Akhil GargPosted Aug 5, 2015, 1:04 PM
Upendra Pratap ShahiPosted Aug 5, 2015, 3:23 AM
Rajeesh MenothPosted Aug 5, 2015, 3:16 AM
yuvaraj kPosted Aug 5, 2015, 3:12 AM
Upendra Pratap ShahiPosted Aug 4, 2015, 8:55 AM
interface add
{
int add(int a, int b);
}
public class adds : add
{
int c = 0;
public int C {
get { return c; }
}
public void add(int a, int b)
{
c = a + b;
}
}
Jignesh TrivediPosted Aug 4, 2015, 3:16 AM
Hi,
Instead of public variable, use property
interface add
{
int add(int a, int b);
}
public class adds : add
{
int c = 0;
public int C {get { return c; }}
public void add(int a, int b)
{
c = a + b;
}
}
try above code.
hope this will help you.