Click here to Skip to main content
15,065,044 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Winform C#: How to access the content of a variable that is in a class of a different namespace, from another one that is in a class of another namespace.


What I have tried:

I created an instance of the second class in the first class by giving it the contents as parameters. But first I defined the second class as it can receive two parameters.
Posted
Updated 8-Mar-21 23:28pm
v3
Comments
OriginalGriff 9-Mar-21 5:24am
   
This is an English language site, and we can only accept and answer questions in that language.
I have run this through Google Translate to produce a probably-good version, but you should check it and make sure it does say what you are actually asking.

1 solution

Try:
C#
namespace One
    {
    public class ClassOne
        {
        public int MyProperty { get; set; }
        public ClassOne(int x, int y)
            {
            MyProperty = x + y;
            }
        }
    }
namespace Two
    {
    public class CalssTwo
        { 
        public void MyMethod()
            {
            One.ClassOne one = new One.ClassOne(23, 34);
            Console.WriteLine(one.MyProperty);
            }
        }
    }
   
Comments
Maciej Los 9-Mar-21 9:05am
   
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900