Matthew Galligan

Hey all,

 

I am currently working on a rather large product and am nearing completion, and I was currently working on some of the Excel/Word conversion and IO routines and I thought to do something like this...

StreamReader sr = new ...blah blah blah

while ((tempString = sr.Readline()) != null)

{

< parsing code here...>
}

 

.. Is there anything absolutely wrong with that type of while or if statement Is it considered bad practice   Will that sort of thing even work right ;p

 



Re: Visual C# General Using assignment in an if/while/ condition?

Friendly Dog

I don't see much of problem there, other than I'd rather use string.IsNullorEmpty




Re: Visual C# General Using assignment in an if/while/ condition?

CalvinR

There is nothing wrong with that, it should work perfectly.





Re: Visual C# General Using assignment in an if/while/ condition?

Matthew Galligan

Alright.. Thanks :)

 

I hadn't ever seen that before and wondered if it was something that was just generally frowned upon.. but its exactly how I need things so ill keep it in there.

 

Doing my first big commercial project.. for the government .. by myself.. im a little nervous lol

I don't see much of problem there, other than I'd rather use string.IsNullorEmpty

 

Didnt notice that one, thats very nice actually. I tend to use 0 length strings whenever I can mostly because I was doing alot of convoluted access apps where I found it much easier to just use empty strings.. I finally convinced the powers that be to get me some proper development tools and im slowly getting a pretty good feel for .NET





Re: Visual C# General Using assignment in an if/while/ condition?

abcdefgqwerty2

You can nest however much *** you feel like reading. As long of course as all the the return values make sense. I miss being able to use multiple assignments like x=y=z=t like in c++.