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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Implement Existing Interface In C#
Vijayaragavan S
Aug 24
2016
Code
835
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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#