|
You may think that your class is not contained in a namespace, but it IS in one. The default name for a namespace is the name of the project.
|
|
|
|
|
Well, that's the point, i would like to be able to copy the class everywhere without changing/adding the projects namespace into the class and still updating the namespace's settings.
Maybe it is impossible, but i like to ask.
|
|
|
|
|
Yeah, it is, you can't change the namespace your code is in.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Like Christian said, you can't do that. The namespace is part of the fully qualified name of the class. Changing it is out of the question.
The only way you can use this class in other projects is to add a reference to it's .DLL. Importing the namespace is optional, but it saves you from having to type the full namespace/class path in your other project's code.
|
|
|
|
|
|
Check 'Ignore HTML tags in this message' to post your XML.
Paul Marfleet
|
|
|
|
|
I posted the .xml file I think...
Jon
|
|
|
|
|
<?xml version="1.0"?>
<database schema-name='products'>
<table name='ProductsInStock'>
<column data-type='text' name='Code' pk='true' fkreferences='Product.Code'>
</column>
<column data-type='int' name='Qty'>
</column>
<column data-type='currency' name='CostPrice'>
</column>
</table>
<table name='Product'>
<column data-type='text' name='ProductID' pk='true'>
</column>
<column data-type='text' name='Description'>
</column>
</table>
</database>
Jon
|
|
|
|
|
This code should work
static void Main(string[] args)
{
int ws = 0;
int pi = 0;
int dc = 0;
int cc = 0;
int ac = 0;
int et = 0;
int el = 0;
int xd = 0;
XmlTextReader textReader = new XmlTextReader("../../sample.xml");
while (textReader.Read())
{
XmlNodeType nType = textReader.NodeType;
if (nType == XmlNodeType.XmlDeclaration)
{
Console.WriteLine("Declaration:" + textReader.Name.ToString());
xd = xd + 1;
}
if (nType == XmlNodeType.Comment)
{
Console.WriteLine("Comment:" + textReader.Name.ToString());
cc = cc + 1;
}
if (nType == XmlNodeType.Element)
{
Console.WriteLine("Element:" + textReader.Name.ToString());
el = el + 1;
if (textReader.HasAttributes)
{
while (textReader.MoveToNextAttribute())
{
Console.WriteLine("Attribute:" + textReader.Name.ToString());
ac = ac + 1;
}
}
}
if (nType == XmlNodeType.Entity)
{
Console.WriteLine("Entity:" + textReader.Name.ToString());
et = et + 1;
}
if (nType == XmlNodeType.Entity)
{
Console.WriteLine("Entity:" + textReader.Name.ToString());
pi = pi + 1;
}
if (nType == XmlNodeType.DocumentType)
{
Console.WriteLine("Document:" + textReader.Name.ToString());
dc = dc + 1;
}
if (nType == XmlNodeType.Whitespace)
{
Console.WriteLine("WhiteSpace:" + textReader.Name.ToString());
ws = ws + 1;
}
}
Console.WriteLine("Total Comments:" + cc.ToString());
Console.WriteLine("Total Attributes:" + ac.ToString());
Console.WriteLine("Total Elements:" + el.ToString());
Console.WriteLine("Total Entity:" + et.ToString());
Console.WriteLine("Total Process Instructions:" + pi.ToString());
Console.WriteLine("Total Declaration:" + xd.ToString());
Console.WriteLine("Total DocumentType:" + dc.ToString());
Console.WriteLine("Total WhiteSpaces:" + ws.ToString());
}
The XmlTextReader has specific methods for iterating through Attributes. Use these when you encounter an Element node.
Paul Marfleet
|
|
|
|
|
Thanks.
Basically rather than use the XmlNodeType.Attribute to read attributes, the code should iterate through the attributes within each element to process them:
if (textReader.HasAttributes)
{
while (textReader.MoveToNextAttribute())
{
Console.WriteLine("Attribute:" + textReader.Name.ToString());
ac = ac + 1;
}
}
Jon
|
|
|
|
|
I edited an old project and saved it as a new name, but everytime i move the project to a new folder with it's new name it gives me an error saying cannot find the file.
When i put it back to the old folder and open it, it shows that the current location is C:\Documents and Settings\Nick\Desktop\My Programs\Halo.sln but I can't change the location, Any one know how to change it?
|
|
|
|
|
Try saving the whole solution in another location.
If you just move the solution-folder, your IDE will get confused and
can't find the files that are listed in the file [solution name].sln.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Alright, I'll try that.
-- modified at 15:29 Saturday 6th October, 2007
Can't save the whole solution to a new folder, Looked threw every menu but there is only a Save Save As Save All no Save All As
-- modified at 15:30 Saturday 6th October, 2007
Btw, i'm using Visual Basics C# Express Edition
|
|
|
|
|
Allright, this is probably a stupid way to do it, but it should work.
First, move the project to the location where you want it to be
(just move the whole folder).
Then do this in Visual Basic C# Express Edition:
On the File menu, select New -> Project from existing code...
Then find the folder that you just moved, and type the path in the
"Where are the files?" textbox, and check the "Include subfolders" checkbox.
The project will then be created at the new location.
Note: I haven't tried this, but it should work.
Virtual1ty
"Any fool can learn from his own mistakes, but a wise man learns from mistakes of others"
|
|
|
|
|
Alright, i'll give it a try.
|
|
|
|
|
Easiest way to do this:
Open your solution. While the solution is open, delete the .sln file in Explorer.
Build your project by going to the Build menu. Before it will build, it will prompt you to save the sln file. Save it to the location of your choosing.
Note, this only works on VS2005. VS2003 will probably barf.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
How do I set the menu strip to a picture and when I right click it, it will open the menu up?
<-- Like an image like that and you right click it, it opens a menu.
|
|
|
|
|
Attach a context menu to the click event of your image
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Thanks,
Can't figure out what to type, is it:
System.Windows.Forms.ContextMenuStrip; ?
|
|
|
|
|
Yes sir. You can do a drag and drop from the designer toolbox, or you can do it like so:
{
System.Windows.Forms.ContextMenuStrip cmuMenu = new ContextMenuStrip();
}
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
|
Yup, you bet. Hope that solution is the one you are looking for!
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
And please try to use more descriptive titles, i've seen about 4 topics with the title 'How do i...' in the last few days.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Can someone direct me regarding coding standards for C#?
I am new to C# and am currentyl moving to C# from VB .NET
Most of my previous programming experience has been within procedural programming languages so OOP is fairly new to me.
C# with curly brackets is entirely new to me.
To give you some idea of how I code I have included a simple code snippet below.
Comments suggestions etc gratefully received(please be gentle or I might return to VB .NET )
<code>
class Prime
{
double testNum, testLimit;
public bool isPrime(double numIn)
{
testLimit = numIn;
testNum = 3;
if (testLimit % 2 == 0)
return false;
while (testLimit > testNum)
{
if (numIn % testNum == 0)
return false;
testLimit = numIn / testNum;
testNum += 2;
}
return true;
}
}
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: Comments suggestions etc gratefully received(please be gentle or I might return to VB .NET)
I think everyone will be nice, NO ONE wants you to return to VB.NET
Everything looks good to me, I have one one suggestion.
GuyThiebaut wrote: if (testLimit % 2 == 0)
Logically, it doesn't matter. I always find it best though to put the constant on the left hand side of a comparision operator. Example:
<code>if (0 == testLimit % 2)</code>
or
<code>
if(string.empty != strMyString)
{
MessageBox.Show("This string contains stuff!");
}
</code>
Like I said, it really doesn't make any difference, but it makes your code a lot more readable, and if someone else happens to be working inside your code, it will give them a better understanding of what is going on. Just my $0.02
Good luck in your quest to learn C#, I think you will find it very similar.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|