String Variable

  • Thread starter Thread starter Yudi Tristianto
  • Start date Start date
Y

Yudi Tristianto

Dear All,

Ok, In Visual Foxpro if i write this code :

Local mApp AS String
mApp = "DO Report.App"

If I Write &mApp it has the same mean with Do Report.App, how can i do
this in C# ?

Thank You
 
Yudi,
Ok, In Visual Foxpro if i write this code :

Local mApp AS String
mApp = "DO Report.App"

If I Write &mApp it has the same mean with Do Report.App, how can i do
this in C# ?

Here is one way to do it:

// declare the delegate to return a string assuming that
// Do Report.App returns a string.
public delegate string ReportAppDelegate( );

....

// Create the delegate that will be used to execute the code.
ReportAppDelegate myApp = new ReportAppDelegate( Report.App );

.....

// execute the code -- you could also pass the delegate
// around before you execute the code.
myApp( );

Another way to accomplish this is through reflection. Hope that helps.

Regards,

Randy
 
Dear All,

Other Example :
i have form ini C# project call the project name is HRD which the name
form is password, in C# if i want call that form i have write this code:

HRD.password frm = new HRD.password();
frm.Show();

The Question , Can I Call that form with this code :

String mForm = "password"
HRD.mForm frm = new HRD.mForm();
frm.Show();

Thanks U
 
Take a look at the Activator class. It let's you instantiate objects given a
class name. If all your forms derive from a common base class (probably the
Form class), you may define your variable as that type. Something like:

Form myForm;
myForm = (Form)Activator.CreateInstance("myassembly",
"mynamspace.password").Unwrap();
myForm.Show();


Arild
 
Back
Top