0

How can Starting and Stopping Processes Programmatically ?

2nd Dec 2016, 1:15 PM
MohammadReza Dehnashi
MohammadReza Dehnashi - avatar
2 Réponses
0
How can implement Dynamic Polymorphism in c# ? Dynamic polymorphism is implemented by abstract classes and virtual functions. using System; namespace PolymorphismApplication { class Shape { protected int width, height; public Shape( int a=0, int b=0) { width = a; height = b; } public virtual int area() { Console.WriteLine("Parent class area :"); return 0; } } class Rectangle: Shape { public Rectangle( int a=0, int b=0): base(a, b) { } public override int area () { Console.WriteLine("Rectangle class area :"); return (width * height); } } class Triangle: Shape { public Triangle(int a = 0, int b = 0): base(a, b) { } public override int area() { Console.WriteLine("Triangle class area :"); return (width * height / 2); } } class Caller { public void CallArea(Shape sh) { int a; a = sh.area(); Console.WriteLine("Area: {0}", a); } } class Tester { static void Main(string[] args) { Caller c = new Caller(); Rectangle r = new Rectangle(10, 7); Triangle t = new Triangle(10, 5); c.CallArea(r); c.CallArea(t); Console.ReadKey(); } } }
2nd Dec 2016, 1:43 PM
MohammadReza Dehnashi
MohammadReza Dehnashi - avatar
0
static void StartAndKillProcess() { Process ieProc = null; // Launch Internet Explorer, and go to facebook! try { ieProc = Process.Start("IExplore.exe", "www.facebook.com"); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } Console.Write("--> Hit enter to kill {0}...", ieProc.ProcessName); Console.ReadLine(); // Kill the iexplore.exe process. try { ieProc.Kill(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } }
2nd Dec 2016, 1:46 PM
MohammadReza Dehnashi
MohammadReza Dehnashi - avatar