|
You should look into LINQ for this, I absolutely LOVE LINQ when working with XML files.
http://www.codeproject.com/KB/linq/LinQ_To_Xml.aspx
That's a good article that shows pretty much exactly how to do what you need.
Sorry for the crappy link, all the fancy JavaScript that formats it doesn't work on my iPhone (stupid safari)
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hello ,
Virtual keyword allows us to override that method in child class.
Now when we declare a class as sealed class then we cant inherit . In That case why it allows us to decalre virtual keyword in static class when any other class inherit it ?
Pls expaln in deatils
Regards,
Jaddu
|
|
|
|
|
It will not allow you to declare a virtual method in a sealed class. You can't have instance members in a static class as well.
|
|
|
|
|
You can't, what makes you think you can?
|
|
|
|
|
You can't. Have you tried it?
In a static class, if you try to create a virtual method the compiler will spit at you with
A static member cannot be marked as override, virtual, or abstract
In a sealed class
... is a new virtual member in sealed class ...
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hey guys,
Can anyone help me in writing the simple regex. Here is the situation:
I have a text file something like:
// Contents
// Contents
MyDataBlock
{
@$
The datablock text
@$
}
// Contents
// Contents
I want to extract "The datablock text". There is single "MyDataBlock" in this text file. It means that i have to extract entire MyDataBlock {...} and then what is inside @$ into a regex group.
I've created a regex. It is successfully extracting following in regex group <b>DataBlockContents</b>:
@$
The datablock text
@$
But i don't want @$ in the regex group DataBlockContents. How can i do so ? The regex i created is:
MyDataBlock[\\w\\s]*{(?<DataBlockContents>[^}]*)}
Imtiaz
|
|
|
|
|
The same way you don't get the { and } in the group?
Do you have control over how the file is formatted? Why use @$ instead of something else?
|
|
|
|
|
Is it possible to pull from somewhere after the application has been compiled to know what it's build version number is so I can show it in a label? I am thinking I can pull if from the assembly but my attempts have failed. Please can someone point me in the right direction?
Here is what I am currently doing and it does not match the build version of the application that I am compiling.
lblAppVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " or " + System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
|
|
|
|
|
Are you looking for something like this?
labelControlVersion.Text = string.Format ( "Version: {0}", Assembly.GetExecutingAssembly ( ).GetName ( ).Version ) ;
|
|
|
|
|
Not quite I want the applications build version... which would show on the project properties screen under the publish tab.
any idea where this is?
|
|
|
|
|
What do you want the text in the label to look like?
To Get This "Ver. 5.1.2 Rev. 3"
Try like this;
Dim avi As System.Version = System.Reflection.Assembly.GetExecutingAssembly.GetName.Version
lblVersion.Text = "Ver. " & Format(avi.Major, "###0").TrimEnd & "." _
& Format(avi.Minor, "###0").TrimEnd & "." & Format(avi.Build, "###0").TrimEnd _
& " Rev. " & Format(avi.Revision, "###0")
Of course this is not the publish version (just saw last post)
|
|
|
|
|
it is very easy tog et this info
This is a code for this
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
lblVersion.Text = v.ToString();
This information is stored in the AssemblyInfo.cs under Node 'Properties' in Solution explorer!
Reg,
Deep
Happy Coding!
|
|
|
|
|
Thanks I learned that c# does not auto increment the version per each build. That was the issue I was having.
|
|
|
|
|
I am having a problem changing the forecolor of a DataGridView header. I have tried the following code:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = dgvMaintenance.ColumnHeadersDefaultCellStyle;
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
The backcolor changes, but the forecolor does not.
I have also tried:
dgvMaintenance.EnableHeadersVisualStyles = false;
DataGridViewCellStyle dgvcs = new DataGridViewCellStyle();
dgvcs.BackColor = System.Drawing.Color.DarkGray;
dgvcs.ForeColor = System.Drawing.Color.White;
dgvMaintenance.ColumnHeadersDefaultCellStyle = dgvcs;
with the same results. I have also added code to change the font and that works too.
What am I doing incorrectly? Thank you for any help.
modified on Wednesday, August 5, 2009 12:26 PM
|
|
|
|
|
i need to check that the content in a textbox is a 6-digit hexadecimal number (or rather, an HTML color code).
How do I do this?
|
|
|
|
|
You could use a regular expression.
There's a bunch of regular expression classes in .net (Start here[^]
If you don't know about regular expressions, you might want to read up a bit on them. There's a site here[^] that's worth looking at.
It's also worth having a tool to test them with before you start coding them. A popular one is Expresso[^].
Simon
|
|
|
|
|
use this function...
bool ValidateColor(string s)
{
if(s.Length != 6)
return false;
for(int i = 0; i < 6; i++)
{
int c = (int)s[i];
if(!(c > 47 && c < 58) || !(c > 64 && c < 71))
return false;
}
return true;
}
..should do the job
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
That is terrible. I see magic constants, a major bug (|| instead of &&) and no acceptance of lower-case hex.
I would suggest:
public static bool ValidateColor(string s, out int value) {
return s!=null && s.Length==6 && int.TryParse(s, out value, NumberStyles.HexNumber);
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yeah, my bad... I wanted to use the parse method but couldn't remember the param for the the NumberStyles bit...
Plus I knew you be around to set me straight
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I want to do the program in c# which is form based,
This is what my program have to do,
It should monitor for the internet explorer, when it is opened it should show a message box. and whenever the url changes in it should be displayed in message box. The url here changed by user.
I dont know how to add beforenaviagte2 event to each ie window,
Where there is a will there is a way
-MS
|
|
|
|
|
No replies...??
Where there is a will there is a way
-MS
|
|
|
|
|
|
Article
Internet Explorer Activity Monitor[^]
The demo project worked fine which contains an exe.
WHen I am opening source code project in my visual studio 2008..After Conversion process, I run it..But it not worked for me.
Please help me to fix this. I am new to c#.
Where there is a will there is a way
-MS
|
|
|
|
|
I have a number of functions that, for one reason or another, return data type object.
If I try and use the + operand (or indeed any arithmetic operator) on types object the compiler throws a wobbly.
How do I tell if a given object supports the "+" operator and, if it does, invoke that "+" operator?
|
|
|
|
|
Hi,
I don't think returning a general object is a good choice.
Have you considered returning a small class or struct holding both the value and the type of the result?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|