|
Have you tried it? It would seem this is very easy to confirm with a 5 minute test-app.
|
|
|
|
|
Here you go, A simple test app.
class Program
{
static void Main(string[] args)
{
ExecTest(typeof(ITest));
ExecTest(typeof(Test));
Console.ReadLine();
}
static void ExecTest(Type type)
{
PropertyInfo prop = type.GetProperty("PropertyName");
if (prop == null)
throw new InvalidOperationException("invalid type - must have PropertyName property");
object[] attrs = prop.GetCustomAttributes(typeof(DefaultSettingValueAttribute), true);
Console.WriteLine("Number of DefaultSettingValueAttribute's on '{1}': {0}", attrs.Length,type.Name);
}
public class Test : ITest
{
#region ITest Members
public string PropertyName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
}
public interface ITest
{
[DefaultSettingValue("test")]
string PropertyName { get; set; }
}
}
|
|
|
|
|
how can i get all the services running or installed in the local machine
|
|
|
|
|
Depending on what you mean by "get", Typing "net start" on your command prompt will list for you the services running on your computer. For programmatic access you can use ServiceController class after importing the corresponding namespace.
|
|
|
|
|
thanx, there is another problem i'm experiencing,i used the servicecontroller to get all the services in the local machine.the problem is some services like(apache) can be started and stopped through this , but services like sqlserver service can't be stopped.
|
|
|
|
|
Hi,
I'm using a Webreference to call a method on the web, which returns data of different size. It would be interesting to see the progress in bytes.
But that Reference generated in Visual Studio doesn't support this feature.
It has only a possible way by using the Async method but how to get the amount of data transfered?
johan.
|
|
|
|
|
I don't see how this is even a reasonable thing to do. You certainly don't know how much data you'll be getting, so a progress bar doesn't make sense. Next, figuring out how much data there is, and then sending it would require at least two queries. That's not very efficient,especially if the query is moderately complex.
"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
|
|
|
|
|
What differences between:
double num= System.Convert.ToDouble(stringVal);
double num= Convert.ToDouble(stringVal);
Thanks!
|
|
|
|
|
No difference actually. System is almost always automatically added in "using" section.
|
|
|
|
|
|
The first example guarantees that the .Net version of Convert.ToDouble will be used.
The second one will use the locally defined version if you've written one, and if not, will use the one defined in the System namespace.
Most programmers don't bother qualifying the Convert object, and just use the 2nd example.
"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
|
|
|
|
|
Hi all,
Is there a way to get list of alphabets for the current culture?
I was able to do it using Unicode script ranges but was not able to get the matching Unicode script name for the current culture.For example, alphabets for locale 'en-US' is under Unicode script 'Basic Latin', but don’t know under which Unicode script rangess the languages 'Spanish', 'French' comes under.
Pls pass on ur comments.
Thanks in advance.
|
|
|
|
|
Hi all,
Is there a way to get list of alphabets for the current culture?
I was able to do it using Unicode script ranges but was not able to get the matching Unicode script name for the current culture.For example, alphabets for locale 'en-US' is under Unicode script 'Basic Latin', but don’t know under which Unicode script rangess the languages 'Spanish', 'French' comes under.
Pls pass on ur comments.
Thanks in advance.
|
|
|
|
|
what's the differences between:
System.Threading.Thread.Sleep(5000)
Thread.Sleep(5000)
Thanks
|
|
|
|
|
Nothing!
System.Threading.Thread.Sleep(5000);
Or
using System.Threading;
Thread.Sleep(5000);
They're the same.
Maybe you should search for using Directive in MSDN.
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
The first is qualified with the full namespace, the last one isn't. The first one will always work, the last one only if you use the appropriate 'using'-clause.
Put the caret on the word 'Thread' of the second example, and hit the F12-button. What do you see now?
|
|
|
|
|
No Difference
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
Hi All
Here is the code below
// List view items starts here.
ListView listView = new ListView();
listView.Bounds = new Rectangle(new Point(3, 16), new Size(900,900));
// Set the view to show details.
listView.View = View.Details;
// Allow the user to rearrange columns.
listView.AllowColumnReorder = true;
// Display check boxes.
listView.CheckBoxes = true;
// Select the item and subitems when selection is made.
listView.FullRowSelect = true;
// Display grid lines.
listView.GridLines = true;
listView.Visible=true;
listView.Columns.Add("File Name", 100, HorizontalAlignment.Center);
listView.Columns.Add("File Location", 100, HorizontalAlignment.Center);
listView.Columns.Add("File size", 100, HorizontalAlignment.Center);
// Add the ListView to the control collection.
this.Controls.Add(listView);
The text in first column header is aligned to left although i have aligned it to center.
The text in other two columns header is aligned to center as set by me.
How can i make the text in first column header to aligned centerally.
Thanks in advance
THE SK(Sandeep Kalra)
I am the One
|
|
|
|
|
Im converting all code from ADO.net to LINQ. In ADO i could add a DateTime field into SQL when adding a record. Im doing the same with LINQ & im getting an error. SqlDateTime Overflow. Must be between 1/1/1753 12:00:00 AM AND 12/31/9999 11:59:59 PM. My format is 2008/11/03 11:00:00 AM. How can I make it take this format & store it in sql server as the required format & not throw this error ?
|
|
|
|
|
There is no standard date format that looks like that. Try the ISO 8601 format "2008-11-03 11:00:00" instead. Otherwise you would have to use the DateTime.ParseExact method with the date format "yyyy/MM/dd HH:mm:ss" to parse the string into a DateTime value.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thx Guffa
I found the problem. A DateTime null in link is not a null in sql. I was only passing one DateTime value & thinking the other DateTime will be null. I passed both DateTime values & no error.
|
|
|
|
|
Hi All,
Please can you assist me with this?
I got this app the imports data from a csv file to the database. The format has changed to Day,Visitors
"October 21, 2008",312 at the day column this the data that goes with this col "October 21, 2008" now i want the app to read whats after the " i want it to read 312.
Please can you assist me on this one?
Thank You
Ndeza,
|
|
|
|
|
I'm writing a simple multi-threaded TCP socket server, in which a new thread is created for each incoming connection (I only have to handle few connection so this should be ok). It is something like this:
static void Main(string[] args)
{
...
TcpListener listener = new TcpListener(IPAddress.Any, servPort);
listener.Start();
while(true)
{
try
{
Socket clntSock = listener.AcceptSocket();
MyProtocol protocol = new MyProtocol();
Thread thread = new Thread(new ThreadStart(protocol.HandleClient));
thread.Start();
}
catch (System.IO.IOException e)
{
...
}
}
}
public class MyProtocol
{
public void HandleClient()
{
...
}
}
I have several newbie questions:
1) How can I access data living in the worker threads? I was thinking to use properties in MyProtocol class for this purpose, like:
public class MyProtocol
{
public int Data
{
get { return _Data; }
set { _Data = value; }
}
private int _Data;
public void HandleClient() {...}
}
The main thread keeps a reference to the MyProtocol objects created, and uses the Data property to exchange data with the thread (with appropriate synchronization using lock to avoid race conditions). Is this ok? Is there any better approach?
2) Which is the correct way to shut down the connection threads? For example, if I want to close the server application, I think I should deal with terminating the connections in a correct manner.
Best regards,
Andrea
|
|
|
|
|
Metal76 wrote: The main thread keeps a reference to the MyProtocol objects created, and uses the Data property to exchange data with the thread (with appropriate synchronization using lock to avoid race conditions). Is this ok? Is there any better approach?
Yeah. This would be OK.
Metal76 wrote: Which is the correct way to shut down the connection threads?
I would add a Stop() method to MyProtocol class. See the below example
volatile bool canContinue = true;
public void HandleClient(){
while(canContinue){
......
}
}
public void Stop(){
canContinue = false;
} You need to call Stop on all the MyProtocol instances created.
Alternatively, you can make the thread as background.
MyProtocol protocol = new MyProtocol();
Thread thread = new Thread(new ThreadStart(protocol.HandleClient));
thread.IsBackground = true;
thread.Start(); So it ends when the main thread ends. But the first one would be the better choice.
|
|
|
|