Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
AnswerRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
Eddy Vluggen7-Mar-19 11:35
professionalEddy Vluggen7-Mar-19 11:35 
AnswerRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
BillWoodruff8-Mar-19 17:11
professionalBillWoodruff8-Mar-19 17:11 
GeneralRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
Member 1016289011-Mar-19 21:43
Member 1016289011-Mar-19 21:43 
GeneralRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
BillWoodruff11-Mar-19 21:50
professionalBillWoodruff11-Mar-19 21:50 
GeneralRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
Member 1016289013-Mar-19 5:59
Member 1016289013-Mar-19 5:59 
GeneralRe: Best way of remembering the history of treeview and other control also across the application in desktop application Pin
BillWoodruff13-Mar-19 6:44
professionalBillWoodruff13-Mar-19 6:44 
QuestionCan classes be nested Pin
Brian_TheLion6-Mar-19 17:26
Brian_TheLion6-Mar-19 17:26 
AnswerRe: Can classes be nested Pin
BillWoodruff6-Mar-19 19:37
professionalBillWoodruff6-Mar-19 19:37 
Before I respond to your specific question, I want to suggest to you that you need to study the basics about what Classes are in C#. Based on my experience with students, I believe you are not clear yet on the important difference between declaring/defining a Class, and creating an instance of a Class.

After you understand that, you can then understand what static Classes are, where the declaration/definition of the Class automatically creates a singular instance.

~

Yes, it is possible to:

1. define a Class within a Class:
using System.Windows.Forms;

namespace YourNameSpace
{
    public class OuterClass
    {
        public OuterClass(int someInt)
        {
            SomeOuterInt = someInt;
        }

        public int SomeOuterInt { set; get; }

        public void SayWhat()
        {
            MessageBox.Show("Outer What");
        }

        public class InnerClass
        {
            public InnerClass(int someInt)
            {
                SomeInnerInt = someInt;
            }

            public int SomeInnerInt { set; get; }

            public void SayWhat()
            {
                MessageBox.Show("Inner What");
            }
        }
    }
}
You can then create either Class:
// requires declaring you are using 'YourNameSpace

OuterClass outerClass = new OuterClass(42);

OuterClass.InnerClass innerClass = new OuterClass.InnerClass(24);

outerClass.SayWhat();
innerClass,SayWhat();
But, think about what this is: it is the equivalent of a recipe/blueprint for the construction of a Class that happens to have another recipe/blueprint inside it.

There is no real "dependency" between the two Classes at run-time: creating an instance of the OuterClass does not create an instance of the InnerClass. You cannot do this:
C#
OuterClass outerClass = new OuterClass(42);

outerClass.InnerClass.SomeInnerInt = 108;

// Error	CS0572	'InnerClass': cannot reference a type through an expression

// or this: innerClass.outerClass.outerInt = 99;

«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

GeneralRe: Can classes be nested Pin
Ralf Meier7-Mar-19 0:08
mveRalf Meier7-Mar-19 0:08 
GeneralRe: Can classes be nested Pin
Brian_TheLion7-Mar-19 10:53
Brian_TheLion7-Mar-19 10:53 
GeneralRe: Can classes be nested Pin
Dave Kreskowiak7-Mar-19 11:50
mveDave Kreskowiak7-Mar-19 11:50 
GeneralRe: Can classes be nested Pin
BillWoodruff8-Mar-19 17:03
professionalBillWoodruff8-Mar-19 17:03 
GeneralRe: Can classes be nested Pin
Brian_TheLion9-Mar-19 18:50
Brian_TheLion9-Mar-19 18:50 
AnswerRe: Can classes be nested Pin
Richard Deeming6-Mar-19 21:46
mveRichard Deeming6-Mar-19 21:46 
QuestionCRTP in c#/.NET? Pin
pr1mem0ver6-Mar-19 13:19
pr1mem0ver6-Mar-19 13:19 
AnswerRe: CRTP in c#/.NET? Pin
BillWoodruff6-Mar-19 21:15
professionalBillWoodruff6-Mar-19 21:15 
GeneralRe: CRTP in c#/.NET? Pin
pr1mem0ver7-Mar-19 5:09
pr1mem0ver7-Mar-19 5:09 
GeneralRe: CRTP in c#/.NET? Pin
BillWoodruff7-Mar-19 7:00
professionalBillWoodruff7-Mar-19 7:00 
AnswerRe: CRTP in c#/.NET? Pin
Gerry Schmitz7-Mar-19 7:26
mveGerry Schmitz7-Mar-19 7:26 
GeneralRe: CRTP in c#/.NET? Pin
BillWoodruff8-Mar-19 17:16
professionalBillWoodruff8-Mar-19 17:16 
GeneralRe: CRTP in c#/.NET? Pin
pr1mem0ver11-Mar-19 16:55
pr1mem0ver11-Mar-19 16:55 
QuestionOnly Numeric Textbox ( Back Space is working ) Pin
Bayram Demirci6-Mar-19 1:31
Bayram Demirci6-Mar-19 1:31 
AnswerRe: Only numeric ( Back Space is working also ) Pin
OriginalGriff6-Mar-19 1:58
mveOriginalGriff6-Mar-19 1:58 
GeneralRe: Only numeric ( Back Space is working also ) Pin
Bayram Demirci6-Mar-19 2:32
Bayram Demirci6-Mar-19 2:32 
GeneralRe: Only numeric ( Back Space is working also ) Pin
OriginalGriff6-Mar-19 2:47
mveOriginalGriff6-Mar-19 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.