Using using to make name references shorter--how?

  • Thread starter Thread starter raylopez99
  • Start date Start date
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.
 
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.
 
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
 
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
 
Back
Top