|
Hi, Whatever i can do in vc++ can it also be done in c#, or is there any thing which is done in vc++ but not in c#???????
|
|
|
|
|
Well, C++ code can run without the .NET runtime, so that's one thing.
Why do you ask ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
i want to know which is more powerful c# or vc++. and is microsoft still supporting vc++ or vc++.net.
|
|
|
|
|
Well, this can be a bit subjective. VC++ was designed to extend the power of C++ with ready to use visual components(technically MFC and SDK).
That means, using VC++ you can do more low level programming compared to C#.
C# on the other hand is generally considered a better option for RAD(Rapid Application Development).
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have created one DataTable with 22 columns. I have filled all the appropiate values on DataTable.
Now i have one DataGridView in which added some of the 22 columns that i want to displayed in DGV.
Then how to bind appropiate column of DGV with same DataTable Columns.
|
|
|
|
|
DateTime? deathTime = null;
if(DateTime.TryParse("somedate",out deathTime))
else
The above shown code won't work as DateTime.TryParse accepts DateTime , not nullable DateTime . So how do we parse a nullable datetime ?
I made it working by the below code, don't know this is the correct approach.
DateTime tmpDateTime;
DateTime? deathTime = null;
if(DateTime.TryParse("somedate",out tmpDateTime))
deathTime = tmpDateTime;
else
Any ideas ?
|
|
|
|
|
Yes, that is the way that you have to do it. The out parameter can not be anything but a DateTime variable.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa.
I wonder, if they can introduce nullable DateTime , why don't they add an overload to TryParse which accepts nullable DateTime ?
|
|
|
|
|
Because every function everywhere would need an override that supports the nullable versions, which would get quite messy
|
|
|
|
|
N a v a n e e t h wrote: I wonder, if they can introduce nullable DateTime, why don't they add an overload to TryParse which accepts nullable DateTime ?
The TryParse method has no use for a nullable variable as out parameter, and it doesn't make sense to introduce something that isn't used.
It could have an overload without an out parameter, that returns a nullable value where a null value represents a failure to parse the string, but then you would have overloads with different semantics. That's not a good way to use overloading.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all,
I've an xml file formatted in C#. I want to rename it using the user define name without disturbing to the file content. How can I do it in C#. Can someone give me a solution for this.
Thanks a lot
I appreciate your help all the time...
CodingLover
modified on Monday, August 18, 2008 1:00 AM
|
|
|
|
|
Ok, I've solve the question my self. Simply use the File.Copy() function to do it.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Dear All,
I want to generate the highlighted code in C# by CodeDom. Now I am able to generate all the codes except the method invoke parameter, which is this one: "IdentityNo"
foreach (CCCRM.PatientRow dr in ta.GetAccessHusbandAndWife(IdentityNo))
{
}
The code that i am using to generate the above c# codes are:
webMethodDeclaration.Statements.Add(new CodeSnippetStatement("foreach (" + module + "." + parameter_1
+ " dr in ta." + methodInfo.Name + "("));
// Parameter list for Table Adapter Method
for (int i = 0; i < methodInfo.GetParameters().Length; i++)
{
string str1 = methodInfo.GetParameters()[i].Name;
webMethodDeclaration.Statements.Add(new CodeSnippetStatement(str1));
}
webMethodDeclaration.Statements.Add(new CodeSnippetStatement("))"));
but apparently they are not right. i was trying to use CodeMehtodInvokeExpression class, but it generates different souce code.
I do appreciate your help and thanks in advance.
Andie Du
|
|
|
|
|
I'm logging what thread my event handler is running on. My original log statement looks like this:
public void myEventHandler()
{
AnotherMethodWhereWorkIsDone(data);
System.Diagnostics.Debugger.Log(0,"", "Current thread is: " + Threading.CurrentThread.GetHashCode());
}
However, it occurs to me that this will actually report the thread that Debugger.Log is running on, and not that of my handler.
So then I snapshotted the CurrentThread.GetHashCode() at the top of my method.
public void myEventHandler()
{
int currHashCode = Threading.CurrentThread.GetHashCode();
AnotherMethodWhereWorkIsDone(data);
System.Diagnostics.Debugger.Log(0,"", "Current thread is: " + currHashCode);
}
But now it occurs to me that I have no idea if my method is guaranteed to be executing on the same thread all the way through. Is there some chance that after AnotherMethodWhereWorkIsDone() executes, my handler will be running on a different thread than when I shapshotted it above AnotherMethodWhereWorkIsDone() ?
|
|
|
|
|
Your assumptions are wrong. The compiler will turn this:
System.Diagnostics.Debugger.Log(0,"", "Current thread is: " + Threading.CurrentThread.GetHashCode());
into this:
int tempInt = Threading.CurrentThread.GetHashCode();
string tempStr = string.Concat("Current thread is: ", tempInt.ToString());
System.Diagnostics.Debugger.Log(0,"", tempStr);
JoeRip wrote: But now it occurs to me that I have no idea if my method is guaranteed to be executing on the same thread all the way through. Is there some chance that after AnotherMethodWhereWorkIsDone() executes, my handler will be running on a different thread than when I shapshotted it above AnotherMethodWhereWorkIsDone()?
Reply·Email·View Thread·PermaLink·Bookmark
No, that is not possible with plain old methods. (It is possible with yield return iterator methods, but that's another story.)
|
|
|
|
|
Thanks, the debugger.log answer does make sense.
For the other part: so my method is guaranteed to remain on the same thread from beginning to end of execution? Even if I called a method from inside it asynchronously (using delegate.BeginInvoke on its delegate)?
That makes me happy.
|
|
|
|
|
how can i play rmvb videos in panel control using c#.net?
i searched for help but couldn't find something.
thanks in advance.
|
|
|
|
|
I think I read somewhere that you can do this with DirectShow..I tried searching for my source but couldn't come up with it.
|
|
|
|
|
thanks swelborn but all i can do with DirectShow just play rm files (sound files) not rmvb files
|
|
|
|
|
I created an application that logs events inside a text file now. The event information looks like this:
This process works like it should but when opening the log file it looks pretty rough and the format of it could be done alot better.
What I proposed was to have it inputted into maybe an xml file with the parent Node being the Event Name and each time this event fires the application will search the xml to see if this Parent Node exists, if it does it creates a child node below that with its value. If it is not in there it creates the Parent Node and creates the child under it with the value.
When I was thinking about doing this I wasn't sure if this solution would be fast enough to handle the event calls. Sometimes the events can be fired rather quickly and I'm afraid there might be some locking involved when writing to the xml file. To solve this I was going to create another class that will act like a buffer between the xml calls and the event calls, kinda like an MSMQ type class.
I know I could get away with doing something like this using mysql or msde or even SQL it'self..the only problem with this is that this is a Packaged Product and needs to be developed as if the client machine does not have SQL or IIS or anything like this installed. The only requirement would be .Net 2.0 - I dont want to force the purchaser to also have these items already.
So basically what I am asking is if anyone here has any idea's how I can have a async, fast read/write option for my logging? Can I get away with using an XML file as my database?
Thanks.
|
|
|
|
|
Swelborn wrote: how I can have a async, fast read/write option for my logging?
Use Log4net[^]
|
|
|
|
|
I have a button that when clicked opens another form. I want it to check and see if the form is already open, and if it is maximize it/bring it to the front. Is this possible?
|
|
|
|
|
Hi !
Are you hiding or closing the form?
here is a method if your are closing the form:
public ParentForm : Form
{
ChildForm frm ; // I assume that your form is a member of the parent form
public ParentForm()
{
// Components
}
public DisplayAChildForm()
{
if (frm == null)
{
frm = new ChildForm();
frm.OnFormClosed += new EventHandler (frmClosed_evnt);
fmr.Show(); // you can use ShowDialog method also
}
}
private frmClosed_evnt(object sender, EventArgs e)
{
frm.OnFormClosed -= new EventHandler (frmClosed_event);
frm = null;
}
}
that's it
|
|
|
|
|
Hi,
In this way you either create or show the form without using events.
On click the ShowChild method is called.
Test for null or disposed and show it if this is the case.
If the form is ok we test if it is minimized then we restore it and then bring it to the front.
Note that Show brings the form to the front only on the first call.
Note - DO NOT CALL ShowDialog - it does not work if the form has been shown before Your application will crash with an InvalidOperationException
public partial class Form1 : Form
{
private Form childForm;
public Form1()
{
InitializeComponent();
}
private void ShowChild()
{
if (childForm == null || childForm.IsDisposed)
{
childForm = new Form2();
childForm.Show();
}
else
{
if (childForm.WindowState == FormWindowState.Minimized)
{
childForm.WindowState = FormWindowState.Normal;
}
childForm.BringToFront();
}
}
private void buttonShow_Click(object sender, EventArgs e)
{
ShowChild();
}
}
Natza Mitzi
|
|
|
|
|
Hi All,
I'm having real troubles with this. Say I've got two classes BaseClass and DerivedClass : BaseClass . How can I cast an instance of BaseClass and convert it into a type of DerivedClass . All I've done in DerivedClass is add two new properties, nothing fancy.
I've tried various methods:
BaseClass baseClass = new DerivedClass();
DerivedClass derivedClass = baseClass as DerivedClass;
DerivedClass derivedClass = (DerivedClass)baseClass;
The C# 3.0 in a Nutshell book uses this illustration which is also failing ...
DerivedClass derivedClass = new DerivedClass();
BaseClass baseClass = derivedClass;
I was under the impression that a Cast was 'workable' and legal provided there was no dataloss int to long for example. Since DerivedClass contains all of the BaseClass properties I was (obviously incorrectly) assuming that this would be an allowable cast. Is there a workaround that doesn't involve mapping each source property to the target type property?
Jammer
if(glass == Glass.Empty){GoToBarAndOrderMoreBeer();}
else {Drink();}
My Blog | Article(s)
|
|
|
|