|
seems OK, why don't you try it?
also have a look at String.IsNullOrEmpty(), that could be a more compact solution.
Saksida Bojan wrote: This class isn't part of GUI.
That's besides the point; the user of your class or method, i.e. the person writing the code that is going to use them (even if it is you), may appreciate getting a specific error message.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Also, if you're writing C# (and not Java) just test string equality with the == operator; there's no need to call Equals directly.
Plus, it's a little more efficient to test for an empty string by checking its Length.
And, as Luc said, IsNullOrEmpty is the preferred way to check this.
Personally, I check each separately so I can give more detailed Exceptions.
|
|
|
|
|
Saksida Bojan wrote:
Yes i have read C# book, but quite while ago. And once i have tried using with many OR operators, i didn't got the desired results
Perhaps you should read it again ?
Saksida Bojan wrote: This class isn't part of GUI.
What is the point of the class reporting if the input is unacceptable, unless it asks the user to correct it ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Saksida Bojan wrote: I don't like too many if statemnts, is it possible to put everything in one If line?
Why don't you ? Let me explain something to you. Writing code that a computer can understand, is easy. One of the worst things about outsourced code, is how illegible it is to humans. Do the poor person who is going to maintain this code in the future a favour, and think about writing legible code, rather than your personal preferences.
Also, how can you provide a detailed error message if all your if statement knows is that one of the parameters is invalid ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
By web app, you mean a windows app that works with the web ? Your app is not ASP.NET, right ?
ninjatruck wrote: I am new to C#,
This is an odd task for someone who is 'new to C#'. How new is new ? What other languages do you know ? Why are you writing this right now ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Well my plan is to use this as part of the code behind class for an ASP.NET website.
I know c++, though I'm not very experienced with that either. I'm writing this now to help a friend who wants this for work. The program will read a .csv, and check URLs based on what it reads. I have everything else working great, but checking the URL isn't working correctly. I've only been working with c# for about a month at this point.
|
|
|
|
|
ninjatruck wrote: Well my plan is to use this as part of the code behind class for an ASP.NET website.
Why would an ASP.NET site be checking if other sites are valid ?
ninjatruck wrote: I know c++, though I'm not very experienced with that either. I'm writing this now to help a friend who wants this for work.
Wait - you don't really know C# or C++, or any other language, but you're writing this to help a friend, who knows so little about programming that they are asking for help from a beginner, yet they are writing code for their job ?
ninjatruck wrote: The program will read a .csv, and check URLs based on what it reads. I have everything else working great, but checking the URL isn't working correctly. I've only been working with c# for about a month at this point.
For someone who has been working with C# for a month to try to write code like this, is insane. You're not learning C# really, you're learning enough syntax to try to use some objects in the .NET framework, without really understand what is going on.
Have you checked what exception is thrown when you go to a URL you expect is valid ? Perhaps the exception type is different.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I hadn't checked what exception was thrown. Thanks for the idea.
Honestly I didn't realize this was such a complicated task when I said I would help.
|
|
|
|
|
ninjatruck wrote: Honestly I didn't realize this was such a complicated task when I said I would help.
Fair enough - you're doing a cool thing to try to help a friend, I am just shocked that based on your limited experience, that he both needs your help, and has a job as a developer.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It is very hard to make. If you PING to server, you can easly get if the server is accsasible. But as i understand from your original post, you wan't to make sure a link is valid not if server is accsasible. Here the problem rises. Server is easly visible, but it will return a custom 404 page.
If you wan't to make for specific sites, you can grab all those sites their custom 404 pages, parse it and check its content.
|
|
|
|
|
I think it should be always better to ping the server rather than practically loading the page.
The site sometimes throws error if proper login to the url is not there.
So Please take out the part after the url and ping that. For instance
http://www.amazon.com/exec/obidos/ASIN/B000GELXHY
should be placed as
http://www.amazon.com
Hope this is working.
|
|
|
|
|
ninjatruck wrote: see if a given URL is valid
that depends on your definition of valid, e.g.:
- responding to pings;
- responding to HTML GET;
- responding to HTML POST;
- responding to other protocols;
...
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
My mistake, essentially I need to see if the url gives a 404 error.
|
|
|
|
|
Read his answer above. He's been doing C# for a month and that month gives him more experience than a friend who works as a programmer, so he's trying to help him out.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
He sure is teaching me new things...
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
cascading menu example in vc++
|
|
|
|
|
sujeet3082@yahoo.com wrote: cascading menu example in vc++
Is this the title of an article or has it some remote connection to C#, i.e. this forum?
|
|
|
|
|
I'm sorry, but it's clear you're not really ready for the big time.
1 - sujeet3082@yahoo.com - using your email as a user id will get you tons of spam
2 - this is the C# forum
3 - your subject line is ridiculously pointless
4 - your 'question' is plain rude. We are real people, you don't just type what you want and we write it for you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
this is not the vc++ forum
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
how can i convert my image into a cartoon usinjg c#?
|
|
|
|
|
With an image processing filter. I'd write it in C++ to make it more efficient and faster, tho.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I noticed that at times I was getting the wrong tag information after loading an image into
memory using Bitmap object.
What I found is that when tags 256, 257 are stored as type short,(3) microsoft reads them as type long. This throughs everything off. I stepped through the tags myself via hex editor, then verified tags were read properly via LeadTools Tiff Tag editor.
I really hoping to use Bitmap.ProperyItems.
Can some one tell me if I am out of my mind ?
|
|
|
|
|
Hi,
Is anyone can tell me how to write a xml file that can return me a result look like this:
<?xml version="1.0"?>
<Items>
<Appointment Start="07/12/2008 11:05:00" End="07/12/2008 14:30:00" .../>
<Appointment Start="07/14/2008 08:15:00" End="07/16/2008 16:40:00" .../>
</Items>
Above is my expected look of my xml file.
These data <Appointment start=".... /> are set EXACTLY THE SAME into a dataset and the table name is "xmldata" And before it is generated I try to loop this dataset and hope to generate a xml look like above. but i alway fail to get a correct format.
its comes like this:
<?xml version="1.0" standalone="yes"?>
<Items>
<xmldata>
<Data>Appointment Start='07/12/2008 11:05:00' End='07/12/2008 14:30:00' Description='Rent this car ' Label='2' Location='city' ResourceId='1' Status='3' Subject='Mr.Brown' </Data>
</xmldata>
<xmldata>
<Data>Appointment Start='07/14/2008 08:15:00' End='07/16/2008 16:40:00' Description='Scheduled repair of this car' Label='4' Location='Service Center' ResourceId='1' Status='2' Subject='Repair' </Data>
</xmldata>
</Items>
XML above by using: ldt_ds.Tables["xmldata"].WriteXml(sourcePath2, false);
Hope someone can help on this.
Thank you.
by CS Tan
modified on Saturday, November 7, 2009 12:06 PM
|
|
|
|
|
You have several options.
If you are using SQL Server, you can use the FOR XML clause in the stored proc you are using to query the data.
You can use XSLT or Linq to XML to transform the given XML into the desired format.
You can use a combination of Linq To XML and Linq to SQL to created the required output.
I know the language. I've read a book. - _Madmatt
|
|
|
|