Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C#

C#

Scheduled Pinned Locked Moved C#
csharplinq
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14193540
    wrote on last edited by
    #1

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }

    D J 2 Replies Last reply
    0
    • M Member_14193540

      using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      So..... you posted an unformatted code snippet and didn't describe a problem or ask a question. What are we supposed to do with this?

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      1 Reply Last reply
      0
      • M Member_14193540

        using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MultipleInheritance { public class Grandparent { protected int x; public Grandparent(int x1) { setX(x1); } public void setX(int x1) { x = x1; } public int getX() { return x; } } public class Parent:Grandparent { public int y; public Parent(int x1,int y1):base(x1) { setY(y1); } public void setY(int y1) { y = y1; } public int getY() { Console.WriteLine ("Value of x is "+base.getX()); return y; } public void modifyX(int t) { this.x = t; } } public class Child:Parent { public int z; public Child(int x1,int y1,int z1): base(x1,y1) { setZ(z1); } public void setZ(int z1) { z = z1; } public int getZ() { Console.WriteLine("Value of y is " + base.getY()); return z; } } class Program { static void Main(string[] args) { int a, b, c; Console.Write("Enter value of a for x : "); a = Convert.ToInt32(Console.ReadLine() ); if (a < 0) { a = 0; } Console.Write("Enter value of a for y : "); b = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter value of a for z: "); c = Convert.ToInt32(Console.ReadLine()); Child q = new Child(a,b,c); Console.WriteLine("Value of z is "+q.getZ()); Console.Write("Enter value of a for x to modify :"); a = Convert.ToInt32(Console.ReadLine() ); q.modifyX(a); Console.WriteLine("Value of z is " + q.getZ()); Console.ReadKey(); } } }

        J Offline
        J Offline
        josda1000
        wrote on last edited by
        #3

        I agree. This is C#.

        Josh Davis
        This is what plays in my head when I finish projects.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups