|
I start an application out of my existing one, but I have a problem to put shell parameters out within the called app. How can I get the "args" ? In the void main ?
|
|
|
|
|
the correct definition for the main should be
static void main(string[] args)
{
...
}
so you can work with the args
|
|
|
|
|
hi,
I have 2 tables with a relationship and want to insert expense information from my asp.net form. PropertyCode is in my expense table in sql server acting as a foreign key. When inserting data do i have to code the fact that property code is >> Property.PropertyCode or something. Currently i cannot insert the data into my table. When working with only 1 table it works fine.
Please help
Regards
|
|
|
|
|
I need to create an object of a particular type. I will get the type information as a string.(For eg:string TypeToCreate="System.Drawing.Font"; ) during runtime.
With this information. How do I create an object?
|
|
|
|
|
Have a look a the MSDN docs for Activator.CreateInstance()
Ryan
|
|
|
|
|
That's exactly the way to go.
You just have to know the fully qualified type name of the class you want to create, otherwise the framework doesn't know which type to create.
For example, you can do this:
string typeToCreateName = "System.Drawing.Font, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
Type typeToCreate = Type.GetType(typeToCreateName);
object o = Activator.CreateInstance(typeToCreate); There are two pitfalls, though:
First, determining the fully qualified type name can be a bit tricky.
Secondly, the type you want to create has to have a parameterless constructor. The example above will fail, because Font doesn't have such a constructor.
Mav
|
|
|
|
|
Try to extract a substring after the last "period" in the string (i.e., "Font"). If only one "type" information is returned in all situations, then simply create the object in a manner like this:
Font font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
However, if you expect objects of different types, the "type" of which can be extracted as above, then use a switch or "if-else if" statement, for example,
if(extractedString == "FONT")
Font font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
else if (extractedString == "SOLIDBRUSH")
SolidBrush redBrush = new SolidBrush(Color.Red);
|
|
|
|
|
Not very dynamic is it? What if there are 500 possibilities of input...500 if/else if's?
|
|
|
|
|
Considering the fact that there are thousands of classes in the .NET Framework that you can create an instance of, are you sure you want to write an "if" statement for each one of them?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You are right, and I fully agree that one may not use this method if the output in the question is going to result into thousands of type of objects.
But, I guess in the practical life, and in a given application of a particular description, one would not be expecting too many types of objects where the above method may work. Moreover, one may have the "catch-all" default "else" statement in the end wherein a generic "object" type may perhaps be considered if at all it serves the purpose with or without casting it further.
Of course, I must admit in all fairness that it depends on the situation concerned, and that I had offered a simple practical solution thinking that only a few types of objects are going to be created.
|
|
|
|
|
hi all ,
I hav project(Win Form with c#)where i'am using sourcegrid2;in this grid i have combobox and i want refer the modification of this combobox; i don't know how i can refer this changement in order to call an event.
please can you help me?
thanks.
|
|
|
|
|
Hey!
I am connecting a CellPhone to the com1 and then i read this serial port from my program.
I know that the CellPhone is supose to give me alot of data all the time, but i oly get about 150 chars when i turn on the cellphone?
Even if the data is not decoded right it shold show all the data right?
BestRegards
jimmy
|
|
|
|
|
Hey!
I need advice!
I are building a Windows Library Control that will connect to CellPhone on the serial port(framework 2.0)
This unit will also share MemoryStreams to other units in the main program. My control will write anything that comes in on the serial port to this Memmory stream.
Problem:
When writing to a Memory strem in my control then the position ends on say 150. When i try to read from a unit that are listening on this Memory Stream, it will begin reading on position 150, and there is no data.
Do i have to use ReadByte and give the offsent and so on, and then manualy remove the readed bytes in the stream?
Best Regards
Jimmy
|
|
|
|
|
|
|
|
|
|
Simple, you don't.
There are projects out there that can do something like only package the .DLL's of the .NET Framework that are absolutely needed by your app to run. These methods are NOT recommended. If you try to install one of the .NET Framework service packs on this kind of installation, you'll find that it won't install because the .NET Framework isn't installed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello,
completely new to c#. created Access DB and windows form. want to display data in textbox. was able to connect DB successfully. but how do you display the data in the textbox?
thanks.
|
|
|
|
|
hi everybody!
Now, I'm designing datetime textbox by C# & ASP.NET, but I face on the problem: users access in our website and login on the datetime textbox by any date type,ex: dd/mm/yyyy or mm/dd/yyyy, .... , in SQL Server, we want to format this by mm/dd/yyyy date type.
How can we do it? function convert(datetime)?
please tell me!
study, study and study more
|
|
|
|
|
how about this version
//get culture info for a specific region
CultureInfo MyCultureInfo = new CultureInfo("de-DE");
DateTimeFormatInfo dt = MyCultureInfo.DateTimeFormat;
// set a new format pattern for the date
dt.ShortDatePattern="yyyy-MM-dd";
//parse the string with the new pattern
DateTime d = DateTime.Parse(textBox1.Text,dt);
the output is done the same way - just take there a different pattern
|
|
|
|
|
When i open my app its the right size, but you can resize it to strange and abnormal sizes.
How do i disable resizing?
|
|
|
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
after that - the form is not sizeable
|
|
|
|
|
And if you want to make them also cannot maximize the app,you can make this property to false;
this.MaximizeBox = false;
|
|
|
|