|
I've tried your example and it returns the the 3rd contact node as expected.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
jrahma wrote: txtContactNumber.Text = xml_documen.GetElementsByTagName("Number")[0].InnerText;
This line will always return the first node.
I think what you are after is;
XmlNode selectedNode = xml_documen.SelectSingleNode("/Resume/Contacts/Contact[@ID='73298407-06fa-462a-be30-254a5318176c']");
txtContactNumber.Text = selectedNode.SelectSingleNode("Number").InnerText;
|
|
|
|
|
I have some function, which makes HttpWebRequest and returns response (string).
Everything works fine except cases when it gets 502 status - Bad Gateway.
In this case try-catch block:
try
{
m_Rresponse = (HttpWebResponse)m_HttpWebRequest.GetResponse();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
if (m_Rresponse.StatusCode == HttpStatusCode.BadGateway || m_Rresponse.StatusCode == HttpStatusCode.GatewayTimeout ||
m_Rresponse.StatusCode == HttpStatusCode.InternalServerError || m_Rresponse.StatusCode == HttpStatusCode.ServiceUnavailable)
{
Console.WriteLine("Sleeping 10 seconds...");
Thread.Sleep(10000);
}
}
The question is why In case of BadGatway "Sleeping 10 seconds..." never printed?
Thanks
|
|
|
|
|
Since I don't have any way of generating a 502 error, I have to assume that is does not set m_Rresponse when it throws an exception - which makes sense, since the throw instruction will terminate processing and transfer control to the catch block immediately. The documentation[^] says "If a WebException is thrown, use the Response and Status properties of the exception to determine the response from the server." which makes more sense to me than relying on an exception completing the instruction that detected the problem.
I am surprised it works for any error, not just 502!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: I am surprised it works for any error
That makes a lot of sense.
|
|
|
|
|
what the meaning of this code?
class MouseInvoker
{
#region Declaration
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
#endregion
#region Move Cursor
public static void move(int X, int Y)
{
Cursor.Position = new Point(X, Y);
}
#endregion
#region Left Click
public static void leftClick(int X, int Y, int count)
{
for (int c = 0; c < count; c++)
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
System.Threading.Thread.Sleep(100);
}
}
#endregion
#region Right Click
public static void rightClick(int X, int Y, int count)
{
for (int c = 0; c < count; c++)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, X, Y, 0, 0);
System.Threading.Thread.Sleep(100);
}
}
#endregion
}
|
|
|
|
|
|
there some error when i klik mouse in pc client, the error on this code
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
|
|
|
|
|
It means you should read this[^] before posting anything else.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hello,
I created an object "polzisce" from a class called Matrika(this is class that creates two dimensional array) and it's constructor takes two parameters.
Those two parameters are actualy X an Y axis and they are not fixed size.
public class Matrika
{
//constructor
public Matrika(int x, int y)
{
int[,] matrika = new int[x, y];
}
}
static void Main(string[] args)
{
Matrika polzisce = new Matrika(5, 5);
}
The question is:
Is object "polzisce" actualy two dimensional array after it is created?
How can i get that two-dimensional array "matrika" from constructor?
Thanks! Alen.
|
|
|
|
|
av7254 wrote: Is object "polzisce" actualy two dimensional array after it is created?
No, it HAS_A two-dimensional array.
av7254 wrote: How can i get that two-dimensional array "matrika" from constructor?
If that's what you want, then why create Matrika at all?
On the other hand, you could write a converter for it.
But why not simply write a static method that takes the two parameters and creates the array?
|
|
|
|
|
your way is simplier but, i want to do it like this.
all i want is to get the x and y value from constructor.
Use cases:
Matrika polzisce = new Matrika(10,20);
Matrika polzisce = new Matrika(5,2);
maybe:
Matrika polzisce = new Matrika(1000,1000);
in this case: Matrika polzisce = new Matrika(5,5);
Constructor runes first when object is created and contains varibles x=5 and y=5(actualy limits of array). I need those two to create two-dimensional array.
I don't know how to access those varibles in the constructor, that i can create 2d array and that object "polzisce" will contain 2d array 5x5
Tnx for all other posts!
I appreciate!
|
|
|
|
|
Not exactly a difficult thing to do: it is pretty common:
Using your original code:
public class Matrika
{
public int[,] arrayOfInts;
public Matrika(int x, int y)
{
arrayOfInts = new int[x, y];
}
}
static void Main(string[] args)
{
Matrika polzisce = new Matrika(5, 5);
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 5; y++)
{
Console.WriteLine(polzisce.arrayOfInts[x, y]);
}
}
} Note that it is not considered good practice to declare the array as public: I did this only to simplify this example.
Note also that the ints are not initialised, so they will all be zero.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thanks!
i have solved this thing it is realy preety simple
<br />
public class Matrika<br />
{<br />
public int mat_x;<br />
public int mat_y;<br />
public Array matrika;<br />
<br />
public Matrika(int x, int y)<br />
{<br />
mat_x = x;<br />
mat_y = y;<br />
matrika = Array.CreateInstance(typeof(int), x, y);<br />
{<br />
But, why did you say that public atributes are no ok?
|
|
|
|
|
av7254 wrote: why did you say that public atributes are no ok
This may take a little while to explain:
Assume you have a class: MyClass which contains a string and an int.
public class MyClass
{
public string UserName;
public int UserID;
....
}
You write your class, you test it, you are happy it works.
So happy, you use it to handle all the user identity work in your entire app!
Then the boss comes along, and says he wants the user name to be in two parts in the database: First name, and second name. Oh, and the userID is not an int, it's going to be a GUID.
How many classes do you have to change to implement this? How much code to you have to change, and test, and document?
If instead you had written the class as:
public class MyClass
{
private string userName;
public string UserName
{
get { return userName; }
set { userName = value; }
}
private int userID;
public int UserID
{
get { return userID; }
set { userID = value; }
}
}
When your dumb boss comes along with his changes, how much rework is there to do? Only the one class, because you can change the internals of MyClass without affecting the outside world:
public class MyClass
{
private string firstName;
private string lastName;
public string UserName
{
get { return firstName + " " + lastName; }
set
{
string[] names = value.Split(' ');
if (names.Length != 2)
{
throw new ApplicationException("Name must have first and last components");
}
firstName = names[0];
lastName = names[1];
}
}
private GUID userID;
public int UserID
{
get { return userID.GetHash(); }
set { userID = GetGUID(value); }
}
}
This is one of the cornerstones of OOP - encapsulation. Never expose your internals more than you have to!
When you are starting off, it seems like a lot of fussing about over nothing! But it very quickly becomes second nature, and does give real benefits - almost from day one. If nothing else, it forces you to think about how your class will be used, and what you want to expose to the outside world. Very often, this affects the internal design in a good way, by the realization that a small change in the original plan can give a more flexible class with wider applications. This leads to more code re-use, and thus better reliability.
I hope that made some sense!
[edit]userID changed to GUID in last example - forgot that when I cut and pasted[/edit]
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Maybe you should google encapsulation, since I think that is what your trying to do.
|
|
|
|
|
polzisce isn't two dimensional array..
matrika is two dimesional, and if you want to access it make it member of class and write a method..
|
|
|
|
|
jayantbramhankar wrote: matrika is two dimesional
No it isn't.
modified on Friday, March 19, 2010 3:41 PM
|
|
|
|
|
int[,] matrika = new int[x, y];
It's not? Granted, there is no word "dimesional", but it seems 2D to me.
|
|
|
|
|
Sorry, I didn't see the lowercase m.
|
|
|
|
|
So, how do i make it member of class, that will conatain x=5 and y=5 in this case.
"polzisce" has to be object wich contains a 2d array wich is specified with this Matrika polzisce = new Matrika(5,5);
Tnx for your answers
|
|
|
|
|
I'm still not sure what you want, but how about this:
public class Matrika
{
private readonly int x ;
private readonly int y ;
public Matrika
(
int X
,
int Y
)
{
this.x = X ;
this.y = Y ;
return ;
}
public int[,]
GetArray
(
)
{
return ( new int [ this.x , this.y ] ) ;
}
}
Matrika m = new Matrika ( 5 , 5 ) ;
int[,] polzisce = m.GetArray() ;
|
|
|
|
|
Hello,
I already use a graphic library (named Irrlicht) with a C# package called Irrlicht.NET (with a file Irrlicht.NET.dll and Irrlicht.NET.xml)
The libary is open source, and has recently delivered a new release.
But the .NET package has not been released (done probably by an other team)
How can I build the new release for C# .net ?
Best regards.
|
|
|
|
|
pedefetoll wrote: How can I build the new release for C# .net
How do you build the C++ code base to use with C#? Or, how do you get the C# source and build it? Did you ask the Irrlicht developer team?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
The C++ code with project files is full available on following site :
(see at http://irrlicht.sourceforge.net/downloads.html)
But I don't know how to convert documented C++ API for managed application (like MS C#).
Best regards
|
|
|
|
|