Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Implement Existing Interface In C#
WhatsApp
Vijayaragavan S
Aug 24
2016
875
0
0
using
System;
class
Point: ICloneable
// implementing IClonable Interface
{
public
int
x, y;
public
Point(
int
x,
int
y) {
this
.x = x;
this
.y = y;
}
public
object
Clone() {
return
new
Point(
this
.x,
this
.y);
}
public
override
string
ToString() {
return
(
"X= "
+ x.ToString() +
" Y= "
+ y.ToString());
}
}
class
Porgram {
static
void
Main(
string
[] args) {
Point p1 =
new
Point(10, 10);
Point p2 = (Point) p1.Clone();
p2.x = 20;
Console.WriteLine(p1);
Console.WriteLine(p2);
Console.ReadKey();
}
}
Implement Existing Interface
C#
Up Next
Implement Existing Interface In C#