|
Would the System.Web.HttpUtility.HtmlDecode() method work?
|
|
|
|
|
This is a C# application and not ASP.NET code or a WebService. Therefore I don't have access to the System.Web namespace. Sorry, I should have mentioned this first time.
Thanks for the response.
Keith
|
|
|
|
|
Did you tried System.Net.WebClient?
<br />
using System.Text;<br />
using System.Net;<br />
<br />
...<br />
<br />
WebClient request = new WebClient();<br />
string PageText = Encoding.Default.GetString(request.DownloadData(Page));<br />
Cheers,
John
|
|
|
|
|
I've tried this but the result is exactly the same regardless of the encoding.
|
|
|
|
|
What happens if you use:
<br />
...<br />
string pagetext = Encoding.ASCII.GetString(request.DownloadData(Page));<br />
...<br />
Sorry if you already have tried it... 
|
|
|
|
|
I tried Encoding.<everything I could think of>.GetString all to no avail.
Actually .ASCII makes things slightly worse!
|
|
|
|
|
It seems that you're getting an unicode encoded page from the web server. Did you tried Encoding.Convert?
<br />
using System.Text;<br />
...<br />
string pagetext = Encoding.Default.GetString(Encoding.Convert(Encoding.Unicode, Encoding.ASCII, request.DownloadData(Page)));<br />
...<br />
What language is your web page/web server? You may try to change Encoding.Unicode to other encoding like UTF8, and Encoding.ASCII to UTF8 if you're still getting wrong results. I'm using the default encoding to read web pages in english/portuguese, and the results are ok for me.
Cheers,
John
|
|
|
|
|
i bound a reference into my program but when i try to start it, an unhandled exception occures: "Object reference not set to an instance of an object"
how can i resolve this?
thanks
John
|
|
|
|
|
Anonymous wrote:
i bound a reference into my program but when i try to start it, an unhandled exception occures: "Object reference not set to an instance of an object"
how can i resolve this?
You need to initialize your object within the application, try adding something like the following, possibly in InitializeComponent() .
this.YourObject1 = new YourObject();
Nick Parker
The only man who never makes a mistake is the man who never does anything. - Theodore Roosevelt
|
|
|
|
|
Hello NG,
I have a standard C# Class-library Project and want it to behave like the SQl-Connection User Control. Means you can drag it from the toolbox on a form and it docks underneath the forms designer.
Does anybody know how to achieve this?
Thanks in advance
Stefan
|
|
|
|
|
You should inherit "Component" not "Control"
//Roger
|
|
|
|
|
Thanks for the fast Answer Roger 
|
|
|
|
|
How to Select a existing directory name by showing a dialog.
( like in .net environment : file->newproject->location )
|
|
|
|
|
Take a look at this [^] article written by Rama Krishna
Cheers,
John
|
|
|
|
|
Hi, all, again!
Would you like to help me, plz?
Have the folow:
I want to create COM+ component with help c#, so, it will use the external(usual) dll-file(my.dll), where contents some logic (com-objects).
This dll good work in usual application, when add it as reference - all ok.
(a have not source for this dll file)
But when i try to link up it in my developed com+ app., - got folow answer from compiler:
"Assembly generation failed -- Referenced assembly 'name of my.dll' does not have a strong name"
is it have not 'strong name'????
i try the next:
al /out:my.dll "?" /keyfile:my_dll.snk
but it don't want to work... i do not understand want is this "?"
and is it right way to solve this problem? and what i must do in this case?
in any case thx.
|
|
|
|
|
I am pretty new to C# and the .NET fromework for that matter. I have recently began working on a Binary Tree class and would like to be able to store any type a user wants to store (i.e. Object). I would like to hide the implementation of this class from the user, however I am having trouble discerning what type the data is that is being stored in this class. I would like to be able to do some sort of "dyanmic cast" on the data and call the appropriate CompareTo() method. I would like to not have to always test on the type of the data and then cast the data to that specific type.
Is this possible?
Hope this makes sense!
Any help would be greatly appreciated.
Thanks
Michael
|
|
|
|
|
Look up typeof. It will do what you want.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
|
David Stone wrote:
Or just myObject.GetType();
Yeah, but don't you have to say
if (myobject.GEtType() == typeof(desiredtype)) ?
David Stone wrote:
BTW, how's that dynamic PDF solution look?
I just established that we have Acrobat 5.0, so I'm going to play with it tomorrow. I had to get something else together today for tomorrow's demo, and yesterday was a holiday here.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Christian Graus wrote:
if (myobject.GEtType() == typeof(desiredtype))
typeof is just going to return the same thing as .GetType() will. They both have System.Type return values.
And, if you look at the remarks on the typeof page:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfTypeofPG.asp[^]...they say that in order to obtain the runtime type of the object, you should use GetType()
So the question is...what are you passing into typeof()?
[edit]Ah, I see now. The example makes it much clearer. You pass the name of a class into typeof(). GetType() returns the type of an object.[/edit]
[edit2]Besides, why wouldn't he just use the is keyword? if(myObject is Object)[/edit2]
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
David Stone wrote:
typeof is just going to return the same thing as .GetType() will. They both have System.Type return values.
Ya. So if I want to know if an object is a string, I need typeof(string) to find that out, unless I arbitrarily create a string. No ?
David Stone wrote:
Besides, why wouldn't he just use the is keyword? if(myObject is Object
Dunno, I will check that out. I'm asking because I'm learning, too. )
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Christian Graus wrote:
Ya. So if I want to know if an object is a string, I need typeof(string) to find that out, unless I arbitrarily create a string. No ?
Alrighty. After some looking around, I finally came to this conclusion:
typeof() takes in a class and spits out the System.Type information characterizing the class.
.GetType() returns the System.Type of the object you call it on.
Thus, remembering that an object is an instance of a class, you could techically do this:
MyObject myObject = new MyObject();
if(myObject.GetType() == typeof(MyObject))
However, using the is keyword is much faster because there isn't any extraction of the types by the CLR. It does some internal checking to see if they match...and then it'll return true if it works.
So that's what I've come to.
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
This kind of comparison is defined with the IComparable interface. Anything that has an ordering should implememnt IComparable.
You should be able to cast the object you're storing to IComparable, and then call CompareTo(), passing in the other oject.
|
|
|
|
|
This seems to be the most reasonable solution I will give it a try and let you know what happens.
Thanks for being helpful.
Michael
|
|
|
|
|
Actually, the IComparable interface isn't going to help you. The CompareTo() method returns an int. It's for sorting lists.
You should however, use the "is" keyword in order to find out if it "is" an instance of that class. Don't use GetType() typeof() or even CompareTo(). Let's say you had a function that looked like this:
public void Cast(object obj)
{
if(obj is OneType)
{
OneType castedType = (OneType)obj;
{
else if(obj is AnotherType)
{
AnotherType castedType = (AnotherType)obj;
{
return;
}
If you really want dynamic casting, this is the way to do it. Using IComparable is not.
Hope that's clearer now.
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|