|
The bold items are the one's I've added/changed.
string seth;
bool anm, beh, st, en;
StreamReader a = new StreamReader(".\\Format.cfg");
while (a.Peek() != -1)
{
seth = a.ReadLine();
if (seth.Trim().Length != 0)
{
if (seth.Trim() == "ABC")
{
anm = true;
}
else if (seth.Trim() == "XYZ")
{
st = true;
}
}
}
|
|
|
|
|
Could it be that you're usually using VB?
In C# you have to write '(' and ')' even for an empty method parameter list (Peek, ReadLine, Trim).
And '==' is the comparison for equality whereas '=' is reserved for assignments only.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
yep, first i used VB but now i m new in C#
anyway thanks buddies but it still have 4 errors
string seth;
bool anm, beh, st, en;
StreamReader a = new StreamReader(".\\Format.cfg");
while (a.Peek() != -1)
{
seth = a.ReadLine();
if (seth.Trim().Length != 0)
{
if (seth.Trim() = "ABC")
{
anm = true;
}
else if (seth.Trim() = "XYZ")
{
st = true;
}
}
}
1.The left-hand side of an assignment must be a variable, property or indexer
2.Cannot implicitly convert type 'string' to 'bool'
3.The left-hand side of an assignment must be a variable, property or indexer
4.Cannot implicitly convert type 'string' to 'bool'
|
|
|
|
|
= is the assignment operator. == is the comparison operator.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
hehe, its working, thanks
|
|
|
|
|
i have a new question that how can i compare bool
for instance
bool as;
if (as=true);
{
}
if i use == instead of = then its giving error
thats my question...
|
|
|
|
|
You compare bools by using the == operator. The = operator is the assignment operator, e.g. a = b means a gets the value of b. The == operator is the equality operator.
If you looked at my earlier answer, you would see that I amended your code to use == instead of = in all the places you had the wrong one (Unfortunately, the bold option didn't seem to show them too well).
|
|
|
|
|
yep i tried first == but it gave error, then i tried with = but it assign it to true
then i post here and when noone reply here then i thought i should do that myself and i read error but all bounce on me,but i read read read
and got the problem, that was i assign 3 bools in a line
my problem solved....!!
Becoming Programmer...
|
|
|
|
|
Hi ALL,
How is it possible to Load a DLL at run time.. . And then load a method from that DLL .. .
SHould i use Reflection concept here ... plz explain???
|
|
|
|
|
|
Thanks for the help .. .
I found my answer in
http://my.execpc.com/~gopalan/dotnet/reflection.html[^]
hmm . .. I searched for the following in GOOGLE
- > dynamically import dll in C#
- > call a method dynamically in C#
but your search string was "APT"
- > c# dynamically load method
|
|
|
|
|
It can be a pain getting the right search keywords. I always put C# first as it's the most relivent keyword.
|
|
|
|
|
I want to download all files from a certain FTP folder to a folder on local machine. I am using C#.NET. Is there anyone to give me any idea how to do that? If someone have code to do that, plz upload it.
Thanks
|
|
|
|
|
|
the link contains a demo which uses the FTPWebRequest class. I want to build a console application not a web application. Can anyone else tell me how to implement this functionality in a window console application usin C#
|
|
|
|
|
This is just an example that shows you how to use FtpWebRequest class. This class does not require the use of a Web application.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
|
Hi all,
I'm starting my app (.NET1.1), celebrating good practice, with an info form, which contains nothing but a picturebox and a timer which closes the window after 3 sec. not more. 1000 times it works without problems but sometimes I get the following exception. How do I have to handle such exception ? I have no idea ?
System.TypeInitializationException: Der Typeninitialisierer für System.Drawing.SafeNativeMethods hat eine Ausnahme verursacht. ---> System.Threading.ThreadAbortException: Der Thread wurde abgebrochen.
at System.Drawing.SafeNativeMethods.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Initialize()
at System.Drawing.SafeNativeMethods..cctor()
--- Ende der internen Ausnahmestapelüberwachung ---
at System.Drawing.SafeNativeMethods.CreateIconFromResourceEx(Byte* pbIconBits, Int32 cbIconBits, Boolean fIcon, Int32 dwVersion, Int32 csDesired, Int32 cyDesired, Int32 flags)
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at System.Drawing.Icon..ctor(SerializationInfo info, StreamingContext context)
at System.Drawing.SafeNativeMethods.CreateIconFromResourceEx(Byte* pbIconBits, Int32 cbIconBits, Boolean fIcon, Int32 dwVersion, Int32 csDesired, Int32 cyDesired, Int32 flags)
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at System.Drawing.Icon..ctor(SerializationInfo info, StreamingContext context)
IntPtr CreateIconFromResourceEx(Byte*, Int32, Boolean, Int32, Int32, Int32, Int32)
Thank's for help
Frank
fracalifa
|
|
|
|
|
Insufficient data, you might want to show the code.
Wild guess: you did use a timer other than Forms.Timer, and its handler
is performing an Illegal Cross-Thread operation on a control (probably the InfoForm itself).
If correct, the remedy is either use Forms.Timer or read up on Control.Invoke
|
|
|
|
|
Here is the code ... nothing spectacular
public class Info_Start : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;
public Info_Start()
{
InitializeComponent();
timer1.Interval = 5000;
timer1.Start();
this.TopMost=true;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Info_Start));
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(512, 360);
this.ControlBox = false;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(520, 368);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(520, 368);
this.Name = "Info_Start";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.TopMost = true;
this.Click += new System.EventHandler(this.Info_Start_Click);
this.Activated += new System.EventHandler(this.Info_Start_Activated);
}
#endregion
private void timer1_Tick(object sender, System.EventArgs e)
{
this.Close();
}
private void Info_Start_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
that's all ...
|
|
|
|
|
fracalifa wrote: nothing spectacular
I agree.
Looks fine at first glance.
Now my guess is, when it fails, it is the timer firing before the form has been completely
loaded (i.e. in the middle of loading the icon, see StackTraceBack).
Remedy might be: wire a Load event and use it to start your timer.
|
|
|
|
|
Hi Luc,
thank you.
I'll try this.
Let's see what happens after the 999th start ....
Frank
|
|
|
|
|
Hi Frank,
you could make a test setup that creates a new form which selfdestroyes after some time,
put everything in a loop, and make the delay a random number say in the range 100...5000
msec (use a static Random !!) then let this run and watch how long it lives on average
(say 3 minutes).
Now apply my (or other) suggestions to fix, and let the same test run say ten times as
long (hence 30 minutes); if that succeeds, you know you have dramatically improved things.
The whole process would take no more than 1 hour, and need little or no human intervention.
Beats launching it manually 1000 times, and not feeling sure whatsoever... (This is
assuming you manage to make the loop fail sooner or later to begin with).
|
|
|
|
|
Hi Luc,
good idea.
My feeling is that this could be a runtime problem (loading the relating lib's on the first start).
Later the lib's are in the file cache and the problem does not occur.
In parallel I will test your suggestion.
Thank's
Frank
|
|
|
|
|
Hai Everybody,
I want to create an application in which i have to have a single CPU but the results has to be displayed in multiple monitors which are all connected to it. Can any one help me by specifying the requirements.
Best Regards,
M. J. Jaya Chitra
|
|
|
|