Using using to make name references shorter--how?

R

raylopez99

Please consider the below and how to make name references shorter--
there has to be a way.

RL

using System;

namespace MyNamesSpace1
{
class ManagerClass
{
int i;
MyNamesSpace1.Form4.InteriorClass myCl_MF4IC; //shorter way?
public ManagerClass()
{
i = 0;
myCl_MF4IC = new MyNamesSpace1.Form4.InteriorClass(); //shorter way?
}

}
}

How to avoid having to type “MyNamesSpace1.Form4.” before the type
name “InteriorClass” when referencing the member class and/or member
member, myCl_MF4IC?

InteriorClass is a class (not nested) that appears inside of Form4,
which is a form (i.e. a class) to the main form, Form1 of the same
namespace, MyNamesSpace1.
 
F

Family Tree Mike

I took your subject line to indicate you knew the answer, but if you
didn't...

using ic = MyNamesSpace1.Form4.InteriorClass;

then in code,

ic myCI_MF4IC;

Please consider the below and how to make name references shorter--
there has to be a way.

RL

using System;

namespace MyNamesSpace1
{
class ManagerClass
{
int i;
MyNamesSpace1.Form4.InteriorClass myCl_MF4IC; //shorter way?
public ManagerClass()
{
i = 0;
myCl_MF4IC = new MyNamesSpace1.Form4.InteriorClass(); //shorter way?
}

}
}

How to avoid having to type “MyNamesSpace1.Form4.” before the type
name “InteriorClass” when referencing the member class and/or member
member, myCl_MF4IC?

InteriorClass is a class (not nested) that appears inside of Form4,
which is a form (i.e. a class) to the main form, Form1 of the same
namespace, MyNamesSpace1.
 
C

Chris Dunaway

using ic = MyNamesSpace1.Form4.InteriorClass;

then in code,

ic myCI_MF4IC;

I know each person is different, but to me, looking at the second line
of code makes me ask : "What is ic?" I don't think I'd shorten it
quite that much. I think I'd probably use something like this:

using f4 = MyNameSpace1.Form4;

and then

f4.InteriorClass myCl_MF4IC;

Cheers,

Chris
 
R

raylopez99

On Sep 6, 9:30 am, "Family Tree Mike"


Thanks FTM. I did not know the answer, and could not find it in any
book, until you posted. I'll make note of this in my notebook.

RL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top