|
If you're using .Net 3.5, you can using System.XML.Linq; and use the XElement object to parse it.
"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
|
|
|
|
|
how can i add a .svc file to a service project with visual studio 2008 when developing a wcf application?
--- Thanks
|
|
|
|
|
Hi,
just right-click on the solution -> add new item -> select "Text File" and change the suggested name into "MyService.svc".
Regards
Sebastian
|
|
|
|
|
hi friends..
i want to retrieve the word document from sql server..
i know to store a document into sql server..
but i dont know how to retrieve the stored document..
i need coding for that in c#
its urgent..
thax
gopal
|
|
|
|
|
|
Hi..
i have successfully stored my word document in SQL server. now i need to retrieve the same document from database. and i want show the same file in my front end..
thaks in advance.....
|
|
|
|
|
That's what you said in your question. Did you have a look at the link I posted?
|
|
|
|
|
I am a novice of .net, It seems that the interface does not do anything ,could you pls tell me above it? I'll very appreciate you if you give some code for compare(one include interface,the other not using interface)
Thanks
|
|
|
|
|
Hi,
since interfaces are nothing .net-specific, you can find them in many languages C#, Java etc. An interface is a desgin pattern to be more formal about, what a class offers to the user of the class. Using interfaces is a method to achieve good system design, higher maintainability and good readibility.
You should always use interfaces if you implement interaction between losely coupled components.
I will post a link here (shame on me it's Java, but was the fastest I could get):
http://java.sun.com/docs/books/tutorial/java/concepts/interface.html[^].
If this is not sufficient, try to find sth. about object-oriented design/architecture/programming.
Does this help you?
Regards
Sebastian
|
|
|
|
|
Interfaces are very useful - even though they don't do anything themselves.
A simple example. Imagine you needed to support more than one type of database, say XML and SQLServer. Obviously, you'd have a class for both types with the necessary methods. The methods exposed by each class would be identical - the only difference would be the implementation inside the methods.
This gives you three possibilities.
1. Have both classes exposed and call the correct one
2. Have an abstract base Database class that XML and SQLServer classes derrive from
3. Create an IDatabase Interface.
1 is not very flexible and would require the calling code to be closely coupled to your DB classes. If you later needed to add Oracle as an option, all your calling code would have to be changed.
2 is kind of pointless, as the base class would never actually be used.
3 gives the perfect solution. XML : IDatabse and SQLServer : IDatabase
Now you can call the methods on an IDatabase instance, and whether XML or SQLServer are called can be decided elsewhere - the calling code will never need to be changed and can be easily extended to support others in future.
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)
|
|
|
|
|
Another benefit of interfaces is that they identify/factor out common behavior among very different classes.
This lets you pass objects of two very different classes that implement interface X to the same parameter in a method that takes an interface X parameter. This lets you reuse that method's code for different classes that implement this interface.
This mechanism also helps make your code more modular. In the above example, the method doesn't know any details about the objects it receives as a parameter, except that they implement interface X. So any non-interface-X changes to the classes passed as a parameter are guaranteed to not impact the method.
|
|
|
|
|
In short an interface is a contract for an ability that you can implement in a class.
For example, a class can implement the IComparable interface, which means that you can compare one instance of the class to another. A method like List.Sort can then sort a list of instances, without the need to know anything at all about the class other than it implements the interface.
To make a method more flexible you can accept parameters of an interface type instead of a specific class. If for example your method needs to loop through some items, it can accept a parameter of the interface type IEnumerable instead of an array . Then your method can be used with any class that implements the interface, like an array , a List , a Queue , a Dictionary.KeyCollection , et.c.
You can also create interfaces to use between your own classes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
An interface is an aspect. For example, all cars have a steering wheel (aspect of steering) but when the steering happens the implementation differs with every manufacturer or they might not, however, a user does not care what happens in the middle. The user only cares about the interface (steering) and the outcome (wheels to turn). Interfaces in programming serve the same purpose. Different classes can have their own implementation but the input and output will always be the same. Consider this:
public class Customer
{
Save()
{
ISaver saver = new DBSaver();
saver.Insert(this); // Here we are asking an implementation of Insert which inserts to the database.
}
}
internal class DBSaver : ISaver
{
public void Save(Customer c)
{
// Here the implementation is to save to DB
}
}
Now if your users decide they do not want to save to databases anymore but want to save to a flat file (not sure why they would do this but who cares), all you have to do is write another class which implements the interface, unit test it and then change only one line of code in Customer as below:
public class Customer
{
Save()
{
ISaver saver = new FlateFileSaver(); // Only this line is changed
saver.Insert(this); // Here we are asking an implementation of Insert which inserts to the flat file.
}
}
That is it and you are good to go. Your UI is still calling CustomerObject.Save() but something different is happening--polymorphism.
There are many other advantages to using Interfaces but this is the basic idea. Sometimes it also helps layout the foundation (blueprint foundation) for something. For example, I do not know how to make a good container class but if I implement the IList interface provided by .NET then I will have a good container will all the appropriate methods. Of course, you have to write good implementation because even if you write garbage inside the implementation that is what will get carried out.
|
|
|
|
|
I have an ArrayList which is used as the datasource of a comboBox:
ArrayList CorrespondenceSources = new ArrayList();
CorrespondenceSources.Add(new CorrAddress("D", "Debtor"));
CorrespondenceSources.Add(new CorrAddress("S", "Solicitor"));
CorrespondenceSources.Add(new CorrAddress("R", "Representitive"));
ComboBox1.DataSource = CorrespondenceSources;
How can I get the ArrayList index for the comboBox element with the value of "S" please?
|
|
|
|
|
Hi,
maybe this helps:
<br />
int iIndex = CorrespondenceSource.IndexOf(ComboBox1.SelectedValue);<br />
Does this help?
Regards
Sebastian
P.S.: Just a hint, did you take a look at List<t>, maybe this suits better than an ArrayList.
|
|
|
|
|
Actually a HashTable will be more ideal but you are right List is better than arraylist.
|
|
|
|
|
I want to create a child form within a mdi that behaves somewhat like a dialog form and I know that I can't do that and that it would defeat the purpose of an mdi all together but here is my dilemma. I need for the child form after a button is clicked on that child form for it to return to the parent form so I can pull values from it. Now if it was a dialogue I could do something like this;
if(form.ShowDialog == DialogResult.OK)
{
any information I want to pull from my dialog I can put here.
}
How can I accomplish this in this case?
|
|
|
|
|
It's a bit of a hack, but you could make an event in the child an fire it when it's about to close. You could even pass the info in the event parameters.. (or just pull them from the child form directly)
|
|
|
|
|
harold aptroot wrote: bit of a hack, but you could make an event in the child
Not a hack, this is exactly what events are for
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)
|
|
|
|
|
That is a good solution and I prefer it. But if you are not familiar with events, a naive solution can also be for the child to call some properties of the parent form and provide the information before it is closed. For example:
class Parent
{
public void foo()
{
MyChildForm child = new MyChildForm();
child.Show();
}
public string SetThisMyChild
{
set
{
_comingFromChild = value;
}
}
private string _comingFromChild;
}
public class MyChildForm
{
public void CloseButton_Click(object sender, EventArgs e)
{
_mainForm.SetThisMyChild = something;
}
}
|
|
|
|
|
Hello everyone,
I met with timeout issue. Here is my whole code. I just send Http request to two local LAN servers and see if response could be received in given time, then I treat the server as healthy, or else I will treat them as unhealthy.
The two servers are simple ASP.Net ASMX Web Serviers Web Servers on IIS. The timeout will happen for both servers are PingServers method executing for 4-5 times successfully. It is strange timeout since the server are pretty fast -- I use IE to access the same URL, it takes less than 1 second to return, but in my code, I set timeout to be 4 seconds, it will prints timeout.
Does anyone have any ideas? Any bugs in my code?
static void PingServers(Object state)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create((String)state);
request.Timeout = 4 * 1000;
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
Console.WriteLine((String)state + " " + ex.ToString());
return;
}
Console.WriteLine((String)state + " is healthy");
return;
}
static Timer[] monitorTimers = new Timer[2];
static void Main(string[] args)
{
monitorTimers[0] = new Timer(PingServers, "http://localserver1/test/test.ashx", 0, 10 * 1000);
monitorTimers[1] = new Timer(PingServers, "http://localserver2/test/test.ashx", 0, 10 * 1000);
Console.ReadLine();
return;
}
thanks in advance,
George
|
|
|
|
|
How to translate the property of the control in the properties window?
For example,there is a Button on the winForm,then many properties is listed in the properties windows,such as Text、BackColor,now I want to translate the name of the property from english into other languange:
for instance:
English Chinese
Text 文本
BackColor 背面颜色
Thanks all in advance!
|
|
|
|
|
Donwload the .NET languagepack[^] of your choice and install it. It doesn't only translate error-messages, but also properties, if I'm not mistaken.
You cannot translate the texts by yourself, since there is no interface.
|
|
|
|
|
Thank Eddy for your answer.
I remember my colleague I have achieved this funtion in his program,not handling by the system languagepack,He can change the Text property of the button with any name.
|
|
|
|
|
The language-pack does it automatically, and the translations are embedded deep in the .NET runtime. It's a low-impact solution to your question, and I suggest you take a look at it before experimenting with sourcecode.
BTW, my Visual Studio IDE @ work uses these Dutch language-packs, and it's bloody annoying to search for something simple like "ForeColor". Not only is the sort-order different (Voorgrondkleur), but it's in a category with a different name. It gets worse when you're facing a localized version of an error - and you need to search the English-based MSDN for the same error.. It doesn't increase the productivity, it just causes more bugs.
Within the computer, everything should remain in a single language. That has nothing to do with the language that the end-user sees. It's just not possible to teach a computer all the localized versions of a boolean.
mctramp168 wrote: I remember my colleague I have achieved this funtion in his program,not handling by the system languagepack,He can change the Text property of the button with any name.
Phone your collegue, ask how he did it
You could also redefine the property-names, as shown in the example below;
[Browsable(false)]
public override System.Drawing.Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor = value;
}
}
[Browsable(true), Category("Appearance")]
public System.Drawing.Color VeurgrondKleur
{
get
{
return this.ForeColor;
}
set
{
this.ForeColor = value;
}
}
This will hide the "ForeColor" from the property-editor in Visual Studio. This example was built on a derivate of a textbox.
I wouldn't dub that a good programming practice. It makes things more complex, without actually adding much value. If you're facing a development-team that has a hard-time with English, then consider upgrading their knowledge of the language. The ROI would be higher when you train the Visual-Studio-user to communicate in English then trying to adapt the environment to the user.
Hope this helps,
I are troll
|
|
|
|