|
Part of the reason it can't be used with strings is that strings are nullable by default. They don't need special treatment.
|
|
|
|
|
I just checked, cause I wasn't sure... string is just a reference type, that acts like value type. So it can point to a null reference of course. My mistake
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
I didn't know about the reference type limitation, but then, I can't think of any value for the concept anyway and have never needed it. Strings are nullable by nature, so they don't count. Thanks for the info!
Will Rogers never met me.
|
|
|
|
|
? can be useful to determine if a choice has been made. To give an example, a person has 0 children because
1. they truely don't have any children or because
2. The value was never set?
Null is a way of explicitly determining if the person has no children. The old way was to set the default to -1. I think null is a better way of expressing that the value was not set.
"You get that on the big jobs."
|
|
|
|
|
To expand on the last reply, it is useful when a variable can validly take the whole range of the type in question, and can also have a 'not set' value. Typically we have either used an invalid value (e.g. testing getchar() for -1 in old school C; -1 is a common 'not set' value in ints still) or created another boolean variable to define whether or not we set a value:
bool customerLikedProduct;
bool customerResponded;
People have also solved that one with a three way enum ...
enum NullableBool { True, False, Maybe }
... but when you do that you lose the ability to use boolean logical operators, compatibility with external data sources or applications, etc.
In these cases, you would like to be able to represent the 'not set' value within one variable. That's what nullable types give you:
bool? customerLikedProduct;
As already mentioned, it's particularly useful for working with databases where null values are a common and standard thing.
For me, using -1 or double.NaN is fine, as long as that can never be a valid value for the variable in question. But there are times when the whole valid range for the natural data type is valid and you should use nullable types.
|
|
|
|
|
Please help me to do this.
|
|
|
|
|
Using VS 2010, right click on your project, click Add New Item, select the General menu item, and select Application Configuration File. I believe that VS 2008 works in a similar fashion.
Will Rogers never met me.
|
|
|
|
|
|
OK. I stumbled on your post and all I saw was a URL pointing to one question that was answered. Do you have some questions regarding that?
Good judgment comes from experience, and experience comes from bad judgment. Barry LePatner
|
|
|
|
|
A spammer, check other messages and click his personal flag.
The best things in life are not things.
|
|
|
|
|
bye bye advert!
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|
|
I want to deny access to a datatable while an outside source is delivering information.
I check on changes to the datatable with a timed delayed method while I am requesting data, when I find that changes to the dt have stopped, then I wish to continue. I do not want to be able to read the dt while incoming info has been processed. When processing has stopped then I checked for changes again, until no changes then I can move on. If I am able to read it, the program may think nothing has changed while info is processed.
Can anyone point me in the right direction or tell me how to turn off access to the dt,
Then I can check it for access at timed intervals.
Thanks in advance.
Michael
|
|
|
|
|
I know that MySQL has commands for locking tables and even rows. Perhaps your database has that as well.
What database are you using?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
MAW30 wrote: I do not want to be able to read the dt while incoming info has been processed.
Why don't you put the data into an alternative table (or tables) then process it in place and then once you are done, post it all at once to the final tables?
That precludes error conditions that end up looking a dependent resource for long periods of time.
|
|
|
|
|
Hello everyone,
I'm working on a small hobby project. I'm making a web crawler for a particular website to extract some useful information from it. I've written information extraction algorithms but I'm completely new to HTTP response stuff. I'm using a HttpWebResponse class of .Net to get the source code of a webpage in form of StreamReader. Now, I'm wondering if I should process each line of stream or I should convert whole streamReader to a string and then process that. Let say, I'm looking for string that should be able to extract .mp3 links on webpage using regex then is it possible that a single link is on two differnt lines of StreamReader, look at the code below..
string url = "http://songs.pk";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string line;
while ((line = sr.ReadLine()) != null)
{
Console.Read();
Console.WriteLine(line);
}
Now can I add some regex matching code here..will this code make sure that it will be able to extract all the .mp3 links from this website? Or should I convert the StreamReader to string and then use regex matching on that string?
I'm sorry, if I'm misunderstanding about StreamReader here, but I need some suggestions to parse the source code of a website. I've searched articles and Google but I'm unable to find something that could help me. Any articles, links or suggestions would be appreciated.
Thanks
Shivam Kalra
|
|
|
|
|
Your code is fine. You will read the HTML code line-by-line from the page and you can process the whole html page line by line. This is a pretty common scenario. You can use a regex to determine if the value from the line-field contains what you are searching for .
|
|
|
|
|
I would read the whole stream (to get the full page content) and use your regexes on that. The streaming is very useful for large downloads, but a web page is easily small enough to work on in memory. StreamReader.ReadToEnd is the easiest way to do that.
|
|
|
|
|
You could also use the HTMLDocument, IHTMLElementCollection, and IHTMLElement to read each tag found in the response and grab the innerHTML if it's a tag you're interested in.
|
|
|
|
|
Is it possible to call a Web Service from C# without first adding a reference to the WS in your project? All the examples I see require a reference. An example would be great.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
|
|
Hello,
Sorry, if its the wrong place to post. I have been doing Embedded Systems (lower level) development on Linux/Windows, in Generic C++ and Visual C++ for the last 5 years or so. I am trying to switch my focus to the new stuff as far as Web applications and latest stuff out there. I would like to do Web Services (middle and Back end not so much web site development). I have started learning C# (winforms) which isn't much different from C++, I guess I can pick up WPF as well. Currently, I am working in robotics and automations which is database driven development, may be its one step closer to what I need.
Can you please give me good tips of how you might approach this? and what topics to really focus on so I might need(may be ASP.net, WCF, DataBases...etc) that can make me a lot more marketable for employers?
Thanks
|
|
|
|
|
Software2007 wrote: Sorry, if its the wrong place to post.
It is, and there's really no excuse for it. You can obviously read, which means you should have EASILY noticed the forum Titled "Web Development" in the menu you had to use to get to THIS forum.
To answer your question, the only real way to learn a new technology is to actually use that technology, and always remember - google is your friend. Create a VERY simple web service and then write a bunch of different clients to connect to it. I'd also put some time into learning about WCF.
Part of writing web services is correctly deploying them, and using them from a remote machine. This means you're going to need another box entirely, or a single machine with enough juevos to run a VM running IIS alongside your own native development deskop. I'm lucky enough to have a 2nd box so I don't have to mess with the sometimes messy bridging of netowrk adapters necessary to be able to communicate with the OS on the virtual desktop.
WPF isn't a back-end technology, and requires the same knowledge to hook an app up to a web service. However, Silverlight is a completely different animal, and it requires still more special knowledge to get it working with a web service.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Thanks for the reply. I am still not too familiar with the architecture, so in a banking example, where clients log on to ask for balances and review account summary, what would be the wcf service, clients? Will the clients be any wpf/winform apps hooking up with the wcf service?
Is this a good example for me to emulate so I can pick up how these thing work?
Thanks
|
|
|
|
|
ok so in a classic web service situation you have an API that you can talk to from client apps (be they web site front ends, mobile apps, desktop apps, or whatever)
the API will be a REST API type thing (basically means you can call it via a URI like a web page) and typically you will get back either XML or JSON (depending on what problem domain you are dealing with)
so you would write essentially a web site that has no face and doesn't output any html as such ... and then you implement the clients who make requests (like custom mini browsers effectively) and get responses in whatever you decided to use (XML,JSON,etc) ... then your clients have to decide how to cache / display / save the data returned from the web service
this is a very simplistic overview but hopefully it isn't insulting or too stupid to be useful as a starting point
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|