SlideShare a Scribd company logo
1 of 40
Download to read offline
Mohammad Shaker
mohammadshaker.com
C# Programming Course
@ZGTRShaker
2011, 2012, 2013, 2014
C# Starter
L07 – Objects Cloning
uses Object Cloning to save the whole engine state
The user can then switch back to any point in time!
See more of
@ http://mohammadshakergtr.wordpress.com/
and @ http://www.youtube.com/watch?v=FM3v0tbdKrs
Cloning Objects – The Concept
Shallow Clone VS Deep Clone
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = "0001";
M2 = M1;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = M1.Number;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = M1.Number;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = M1.Number;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Cloning Objects
using System;
using System.Reflection;
namespace ConsoleApplicationCourseTest
{
class Mobile
{
public string Number { set; get; }
}
class MainClass
{
public static void Main(String[] args)
{
Mobile M1 = new Mobile(), M2 = new Mobile();
M1.Number = "0000";
M2.Number = M1.Number;
Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number);
}
}
}
M1 Num. 0000
M2 Num. 0000
Press any key to continue...
Try to Clone with IClonable interface
Cloning Objects
• ICloneable interface
• Another disadvantage of ICloneable is that the Clone method returns an object,
hence every Clone call requires a cast:
public interface ICloneable
{
object Clone();
}
Person joe = new Person();
joe.Name = "Joe Smith";
Person joeClone = (Person)joe.Clone();
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
joe FullName: Joe Smith
bob FullName: Joe Smith
joe FullName: Joe Smith
bob FullName: Bob PopUp
Press any key to continue...
namespace ConsoleApplicationCourseTest
{
class MainClass
{
public class Person : ICloneable
{
public string Name;
object ICloneable.Clone()
{
return this.Clone();
}
public Person Clone()
{
return (Person)this.MemberwiseClone();
}
}
public static void Main(String[] args)
{
Person joe = new Person();
joe.Name = "Joe Smith";
Person bob = (Person)joe.Clone();
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
bob.Name = "Bob PopUp";
Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name);
}
}
}
joe FullName: Joe Smith
bob FullName: Joe Smith
joe FullName: Joe Smith
bob FullName: Bob PopUp
Press any key to continue...
But this is all a headache!
The fastest way to deep clone..
The fastest way to deep clone
The fastest way to deep clone
[Serialization]
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
public static class ObjectCopier
{
/// <summary>
/// Perform a deep Copy of the object.
/// </summary>
/// <typeparam name="T">The type of object being copied.</typeparam>
/// <param name="source">The object instance to copy.</param>
/// <returns>The copied object.</returns>
public static T Clone<T>(T source)
{
if (!typeof(T).IsSerializable)
{
throw new ArgumentException("The type must be serializable.", "source");
}
// Don't serialize a null object, simply return the default for that object
if (Object.ReferenceEquals(source, null))
{
return default(T);
}
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(stream);
}
}
}
End of Course
Go and have some fun and come back for the next
Advanced C# Course
Take a Look on my other courses
@ http://www.slideshare.net/ZGTRZGTR
Available courses to the date of this slide:
http://www.mohammadshaker.com
mohammadshakergtr@gmail.com
https://twitter.com/ZGTRShaker @ZGTRShaker
https://de.linkedin.com/pub/mohammad-shaker/30/122/128/
http://www.slideshare.net/ZGTRZGTR
https://www.goodreads.com/user/show/11193121-mohammad-shaker
https://plus.google.com/u/0/+MohammadShaker/
https://www.youtube.com/channel/UCvJUfadMoEaZNWdagdMyCRA
http://mohammadshakergtr.wordpress.com/
C# cloning objects course

More Related Content

What's hot

The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploitsPriyanka Aash
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
C++ Windows Forms L02 - Controls P1
C++ Windows Forms L02 - Controls P1C++ Windows Forms L02 - Controls P1
C++ Windows Forms L02 - Controls P1Mohammad Shaker
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance Mohammad Shaker
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java SwingTejas Garodia
 
C++ Windows Forms L05 - Controls P4
C++ Windows Forms L05 - Controls P4C++ Windows Forms L05 - Controls P4
C++ Windows Forms L05 - Controls P4Mohammad Shaker
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Kotlin puzzler
Kotlin puzzlerKotlin puzzler
Kotlin puzzlerMireukPark
 
JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)HimanshiSingh71
 
Python functions
Python functionsPython functions
Python functionsToniyaP1
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - PraticalsFahad Shaikh
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 

What's hot (20)

Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
 
The art of reverse engineering flash exploits
The art of reverse engineering flash exploitsThe art of reverse engineering flash exploits
The art of reverse engineering flash exploits
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
C++ Windows Forms L02 - Controls P1
C++ Windows Forms L02 - Controls P1C++ Windows Forms L02 - Controls P1
C++ Windows Forms L02 - Controls P1
 
Class method
Class methodClass method
Class method
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java Swing
 
C++ Windows Forms L05 - Controls P4
C++ Windows Forms L05 - Controls P4C++ Windows Forms L05 - Controls P4
C++ Windows Forms L05 - Controls P4
 
final project for C#
final project for C#final project for C#
final project for C#
 
Vb.net iv
Vb.net ivVb.net iv
Vb.net iv
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Kotlin puzzler
Kotlin puzzlerKotlin puzzler
Kotlin puzzler
 
JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)JDBC (JAVA Database Connectivity)
JDBC (JAVA Database Connectivity)
 
Python functions
Python functionsPython functions
Python functions
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - Praticals
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 

Viewers also liked

Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieMohammad Shaker
 
XNA L11–Shaders Part 2
XNA L11–Shaders Part 2XNA L11–Shaders Part 2
XNA L11–Shaders Part 2Mohammad Shaker
 
XNA L10–Shaders Part 1
XNA L10–Shaders Part 1XNA L10–Shaders Part 1
XNA L10–Shaders Part 1Mohammad Shaker
 
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D EnvironmentUtilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D EnvironmentMohammad Shaker
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPMohammad Shaker
 
WPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D AnimationWPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D AnimationMohammad Shaker
 
C# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationC# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationMohammad Shaker
 
WPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and TemplatesWPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and TemplatesMohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
C# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFC# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsMohammad Shaker
 
Car Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS SystemsCar Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS SystemsMohammad Shaker
 
XNA L02–Basic Matrices and Transformations
XNA L02–Basic Matrices and TransformationsXNA L02–Basic Matrices and Transformations
XNA L02–Basic Matrices and TransformationsMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 

Viewers also liked (18)

Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
 
XNA L11–Shaders Part 2
XNA L11–Shaders Part 2XNA L11–Shaders Part 2
XNA L11–Shaders Part 2
 
Delphi L02 Controls P1
Delphi L02 Controls P1Delphi L02 Controls P1
Delphi L02 Controls P1
 
XNA L10–Shaders Part 1
XNA L10–Shaders Part 1XNA L10–Shaders Part 1
XNA L10–Shaders Part 1
 
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D EnvironmentUtilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
WPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D AnimationWPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D Animation
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
C# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationC# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow Foundation
 
WPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and TemplatesWPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and Templates
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
C# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFC# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCF
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
Car Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS SystemsCar Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS Systems
 
XNA L02–Basic Matrices and Transformations
XNA L02–Basic Matrices and TransformationsXNA L02–Basic Matrices and Transformations
XNA L02–Basic Matrices and Transformations
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 

Similar to C# cloning objects course

C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsMohammad Shaker
 
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation PrimitivesSynack
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Mikhail Sosonkin
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingPokequesthero
 
Kotlin for android
Kotlin for androidKotlin for android
Kotlin for androidAhmed Nabil
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)sdrhr
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationIvan Dolgushin
 
wk2utility classes.zipApplicationUtilities.csusing System.docx
wk2utility classes.zipApplicationUtilities.csusing System.docxwk2utility classes.zipApplicationUtilities.csusing System.docx
wk2utility classes.zipApplicationUtilities.csusing System.docxericbrooks84875
 
Kotlin / Android Update
Kotlin / Android UpdateKotlin / Android Update
Kotlin / Android UpdateGarth Gilmour
 
Painless Persistence with Realm
Painless Persistence with RealmPainless Persistence with Realm
Painless Persistence with RealmChristian Melchior
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup itPROIDEA
 
Intro to object oriented programming
Intro to object oriented programmingIntro to object oriented programming
Intro to object oriented programmingDavid Giard
 

Similar to C# cloning objects course (20)

C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and Objects
 
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
 
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java day 2016.pptx
Java day 2016.pptxJava day 2016.pptx
Java day 2016.pptx
 
Kotlin for android
Kotlin for androidKotlin for android
Kotlin for android
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
 
War Simulation
War SimulationWar Simulation
War Simulation
 
Hems
HemsHems
Hems
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
wk2utility classes.zipApplicationUtilities.csusing System.docx
wk2utility classes.zipApplicationUtilities.csusing System.docxwk2utility classes.zipApplicationUtilities.csusing System.docx
wk2utility classes.zipApplicationUtilities.csusing System.docx
 
Kotlin / Android Update
Kotlin / Android UpdateKotlin / Android Update
Kotlin / Android Update
 
Dlr
DlrDlr
Dlr
 
Painless Persistence with Realm
Painless Persistence with RealmPainless Persistence with Realm
Painless Persistence with Realm
 
Java oops features
Java oops featuresJava oops features
Java oops features
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
 
Intro to object oriented programming
Intro to object oriented programmingIntro to object oriented programming
Intro to object oriented programming
 

More from Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to GamesMohammad Shaker
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenMohammad Shaker
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesMohammad Shaker
 
Roboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringRoboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringMohammad Shaker
 

More from Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to Games
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSeven
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in Games
 
Roboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringRoboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software Engineering
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

C# cloning objects course

  • 1. Mohammad Shaker mohammadshaker.com C# Programming Course @ZGTRShaker 2011, 2012, 2013, 2014 C# Starter L07 – Objects Cloning
  • 2. uses Object Cloning to save the whole engine state The user can then switch back to any point in time!
  • 3. See more of @ http://mohammadshakergtr.wordpress.com/ and @ http://www.youtube.com/watch?v=FM3v0tbdKrs
  • 4. Cloning Objects – The Concept
  • 5. Shallow Clone VS Deep Clone
  • 6. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } }
  • 7. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 8. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 9. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 10. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 11. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 12. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = "0001"; M2 = M1; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 13. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = M1.Number; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 14. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = M1.Number; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 15. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = M1.Number; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 16. Cloning Objects using System; using System.Reflection; namespace ConsoleApplicationCourseTest { class Mobile { public string Number { set; get; } } class MainClass { public static void Main(String[] args) { Mobile M1 = new Mobile(), M2 = new Mobile(); M1.Number = "0000"; M2.Number = M1.Number; Console.WriteLine("M1 Num. {0} nM2 Num. {1}", M1.Number, M2.Number); } } } M1 Num. 0000 M2 Num. 0000 Press any key to continue...
  • 17. Try to Clone with IClonable interface
  • 18. Cloning Objects • ICloneable interface • Another disadvantage of ICloneable is that the Clone method returns an object, hence every Clone call requires a cast: public interface ICloneable { object Clone(); } Person joe = new Person(); joe.Name = "Joe Smith"; Person joeClone = (Person)joe.Clone();
  • 19. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 20. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 21. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 22. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 23. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 24. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } }
  • 25. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } } joe FullName: Joe Smith bob FullName: Joe Smith joe FullName: Joe Smith bob FullName: Bob PopUp Press any key to continue...
  • 26. namespace ConsoleApplicationCourseTest { class MainClass { public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone(); } public Person Clone() { return (Person)this.MemberwiseClone(); } } public static void Main(String[] args) { Person joe = new Person(); joe.Name = "Joe Smith"; Person bob = (Person)joe.Clone(); Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); bob.Name = "Bob PopUp"; Console.WriteLine("joe FullName: {0} nbob FullName: {1}", joe.Name, bob.Name); } } } joe FullName: Joe Smith bob FullName: Joe Smith joe FullName: Joe Smith bob FullName: Bob PopUp Press any key to continue...
  • 27. But this is all a headache!
  • 28. The fastest way to deep clone..
  • 29. The fastest way to deep clone
  • 30. The fastest way to deep clone [Serialization]
  • 31. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 32. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 33. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 34. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 35. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 36. public static class ObjectCopier { /// <summary> /// Perform a deep Copy of the object. /// </summary> /// <typeparam name="T">The type of object being copied.</typeparam> /// <param name="source">The object instance to copy.</param> /// <returns>The copied object.</returns> public static T Clone<T>(T source) { if (!typeof(T).IsSerializable) { throw new ArgumentException("The type must be serializable.", "source"); } // Don't serialize a null object, simply return the default for that object if (Object.ReferenceEquals(source, null)) { return default(T); } IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); using (stream) { formatter.Serialize(stream, source); stream.Seek(0, SeekOrigin.Begin); return (T)formatter.Deserialize(stream); } } }
  • 37. End of Course Go and have some fun and come back for the next Advanced C# Course
  • 38. Take a Look on my other courses @ http://www.slideshare.net/ZGTRZGTR Available courses to the date of this slide: