|
What you want is an HTML parser (google is your friend). Don't mess around with regex because you'll spend a lot of time trying to figure it out. Believe me - downloading a parser will be much faster.
"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 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hear hear! This is a wheel best not reinvented.
|
|
|
|
|
Hey guys
I need to get the size of a string in bytes, how do i do that
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: the size of a string in bytes
what size? what is your purpose?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Im trying to send a request to a IM(MXit) server, to protocol documentation states that the length of the request must be pre-pended to the request...
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Hi,
if the API you are using expects a Unicode string, then I would expect the length is the number of characters, not bytes.
in the more likely case the API expects a byte array, you would need an Encoding (maybe Encoding.ASCII, Encoding.UTF8, or new Encoding(1252)) and use its GetBytes() method. In such case the length would be the length of the byte[].
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
You mean the size of the string in a specific encoding? for example,
Encoding.UTF8.GetByteCount(theString);
Or the size of a string object in memory? which depends on implementing platform[^]
Eslam Afifi
|
|
|
|
|
If i have a string, lets say the string is "System.Float".
Is there anyway i can get the type from that string? (ie a float).
And do something like this:
Float f = new GetMagicTypes<"System.Float">();
|
|
|
|
|
Huh?
You can get the type using: Type.GetType("System.Single"), etc, but you can't use that as a template argument.
And your example is going to create a GetMagicTypes object, not a float.
GetMagicTypes<float> f = new GetMagicTypes<float>();
What are you trying to accomplish?
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
What im doing is that im parsing the object type from xml, so i need a way to allocate an object of the type in the string.
Something like this then maybe:
Float f = new<type.gettype("system.float")>();
Ofcourse i could do this:
if("System.Float" == type)
Float f = new System.Float;
elseif("System.Boolean" == type)
Boolean b = new System.Boolean;
But that is an unnessecary thing if c# has support for string<->type conversion
|
|
|
|
|
Well...you can't know at compile time what you're going to get at runtime, so you can't strongly type it.
If you want the xml value to be a float, then you'll have to coerce it.
float f;
float.TryParse(your xml value, out f);
Same with all the other types, int, bool, etc.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
Hi,
have a look at the Activator class and its CreateInstance method.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Awesome! many thanks, just what i was looking for
|
|
|
|
|
This will still just get you an object, so if you want to do anything with it, you'll have to cast it to the type you want, which might be fine for what your doing?
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
A) This may be a good place to use var .
B) Accessing Reflection can be time-consuming, so I prefer to cache the results.
C) Typically, in situations like this, I use a Dictionary. Here I might suggest a Dictionary<string,System.Reflection.ConstructorInfo> . Populate it with the expected/allowed types your application should support. Then something like:
var x = dic [ somestring ].Invoke() ;
would invoke the constructor and return an instance of whatever type was requested (or fail). However, it's Sunday morning and I'm still on my first cup of coffee, so I don't expect the above syntax to be correct (I'm pretty sure it isn't, but it should communicate the concept well enough).
D) If you want to support types that aren't known at compile time, you will need to learn how to dynamically load assemblies. There are several articles on that here.
|
|
|
|
|
Real programmers start lettering with @) not A)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
A is just a meaningless label. Maybe I'll use GUIDs next time.
|
|
|
|
|
|
Hi all,
Can any one please tell me that how can i change the color of second line in rich text box?
My requirement is first line in richtext box should be blue and second line should be red.
Thanks in advance
Lijo
|
|
|
|
|
select the text and change selection color
e.g.
RTB.SelectionColor = Color.Red;
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
First you need to change the color of the text before putting it in the rtb.
rtb.SelectionColor = System.Drawing.Color.Red;
rtb.AppendText(outText);
changing other attributes
rtb.SelectionColor = System.Drawing.Color.Blue;
System.Drawing.Font fBold = new System.Drawing.Font("Courier New", 10, fontBold);
rtb.SelectionFont = fBold;
rtb.AppendText(outText);
good luck
|
|
|
|
|
Dear sir,
there are two projects in single dotnet IDE. every project included in separate namespaces.
i want to use one project reference to another project or namespace .
how can i do this???
i tried to use through "using " keyword , but it is not working and giving runtime error.
like this:
The type or namespace name 'TechWayHosting' could not be found (are you missing a using directive or an assembly reference?) D:\Yogesh_Backup\yogesh\New Folder\TechWayHosting-1st April 2009\FTPLibrary\User Controls\FileBrowserControl.cs FTPLibrary
yogesh
|
|
|
|
|
yogesh_softworld123 wrote: are you missing a using directive or an assembly reference?
You have a using directive, so what could be missing?
right-click on the project in the solution pane and fix it.
yogesh_softworld123 wrote: giving runtime error
this is a compile-time error, not a run-time error. Your app is not running yet.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
You used the "using" directive, which is fine... But before that did u add the reference of the other project in "Add Reference" of your current project...?
|
|
|
|
|
i have a form, i want to change the time and/or date of the system
and now i have found the following code but it just generate errors
i don't know what is exactly the problem
it is not a run time error, it is a compilation error
i am using C# in visual studio 2008
here is the error message :
"Error 39 Attribute 'StructLayout' is not valid on this declaration type. It is only valid on 'class, struct' declarations. D:\visual studio projects\firstCSharp\firstCSharp\settings.cs 16 12 firstCSharp"
here is the code
public partial class settings : Form
{
[StructLayout(LayoutKind.Sequential)]
[DllImport("kernel32.dll", EntryPoint = "SetSystemTime", SetLastError = true)]
private static extern bool SetSystemTime(ref MyDateTime st);
[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)]
private extern static void GetSystemTime(ref MyDateTime sysTime);
please tell me how can i handle this error
thank you everybody in Advance
|
|
|
|