|
try using a singleton to handle the exception...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
i started with vb.net and now i am doing c# i am totally confused...which is the better....in efficeincy matters...
can anyone tell me some valid points where c# scores over vb.net or vice versa...
thank you!
|
|
|
|
|
They are as efficient as each other. Which you should use is largely a matter of taste. There are a few differences in features. For example, you can do operator overloading in C# but not in VB. You can also write unsafe code in C# - code that runs outside the managed execution environment.
I'm sure others will be able to tell you more deatils. If not, try searching on "C# vs. VB.NET" on Google. I think there is a comparison table somewhere in the Visual Studio Help and in the online MSDN library.
Kevin
|
|
|
|
|
They are not as efficient as one another. C# is faster and more powerful than VB.NET: http://www.codeproject.com/dotnet/PrimeNumbersProjects.asp[^]
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
My answer was based on statements from Microsoft. Some time ago I also saw another statistical analysis which showed little or no difference between C# and VB .NET. I guess it depends on the nature of the programming task you want to perform. This article concentrates on a specific mathematical task. And even then the bigger the size of the problem the smaller the differences. For more general tasks, e.g., a typical ASP.NET web application, I suspect you will not see much difference.
As for C#'s being more powerful, what do you mean by that? If you mean it can do more things than VB .NET, such as call unsafe code, then I would agree. There are other differences but I don't regard them as being significant "power" differentiators.
Kevin
|
|
|
|
|
Kevin McFarlane wrote:
My answer was based on statements from Microsoft.
I know. I just get really tired of seeing the same old stuff. Believe me, I've used both languages and C# is definitely faster than VB.NET. Sometimes I've even noticed that my ASP.NET apps run a lot faster using C# than VB.NET.
Kevin McFarlane wrote:
As for C#'s being more powerful, what do you mean by that?
Unsafe code is one of them. Others are Operator Overloading, built in XML documentation, tighter integration with .NET, and of course...lack of the Beep() function.
But seriously, C# is just an all around cleaner language than VB.NET is. Especially when VB.NET still has the MsgBox() function and all the old compatibility namespace stuff.
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
The CLR gives the unique opportunity not to bother at all the language the classes are written in. You can for instance build a class library using a language such like VB.NET just because VB is a unique language for... for...well VB is a language... well VB is ....well never mind...you may use C# to build a class library, produce an assembly, and then in another non-C# project you reference that assembly.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
vb.net = 6 chars
c# = 2 chars
therefore its 3 times quicker to write in c#
HTH
actually the point is that .net is written in c# not vb.net, which is a big clue
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hello ..
For some reason the components that were originally in my toolbox are now gone. There are only a few showing without the ICONS for them and I can't remember all the components that were default ...
Is there anyway to bring back the default components ?
Thks in advance ..
jon
Jon ...
|
|
|
|
|
Right click on the toolbox and choose "Customize Toolbox", then click the Reset button on the dialog that comes up.
James
Sig code stolen from David Wulff
|
|
|
|
|
|
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot add a top level control to a control.
I get this when I attempt to doc an outlook type toolbar form to my already existing form.
|
|
|
|
|
So you're trying to add one form to another? You can't do that unless the parent form is MDIParent = true; and the child form is MDIChild = true; and I don't think that's what you want to do. You could take the Outlook Toolbar type control and putting that into the parent form. That would work.
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
Yes that is what I am trying to do. All I see is an MDIContainer. Neither of of forms have the option for mdiParent and mdiChild.
|
|
|
|
|
I found the methods for the objects. Having trouble actually setting them correctly dispite the given examples I found online? Any idea what to set (syntax) and where to set it from this point?
Derek
|
|
|
|
|
Look at James' explanation, it's way better than mine would be. *David humbly cedes control of the thread to James, realizing of course, that the C# Guru has, once again, bestowed his knowledge upon us... *
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
David Stone wrote:
So you're trying to add one form to another? You can't do that unless the parent form
Yes you can
Two forms, Parent and Child:
Child.TopLevel = false;<br />
<br />
Parent.Controls.Add(Child);<br />
<br />
Child.Show();
James
Sig code stolen from David Wulff
|
|
|
|
|
Two forms, Parent and Child:
Child.TopLevel = false;<br />
<br />
Parent.Controls.Add(Child);<br />
<br />
Child.Show();
That should do it
James
Sig code stolen from David Wulff
|
|
|
|
|
I ran the producer/consumer threading lock example, and set the breakpoints right after the cell locked. From my understanding, anything within a lock block should by synchronized, and only one thread can enter into a locked block at a time. However, when the program is run, the breakpoints are hit on both of the producer and consumer threads. How can this be?
The code used:
<br />
using System;<br />
using System.Threading;<br />
<br />
public class MonitorSample<br />
{<br />
public static void Main(String[] args)<br />
{<br />
int result = 0;
Cell cell = new Cell( );<br />
<br />
CellProd prod = new CellProd(cell, 20);
CellCons cons = new CellCons(cell, 20);
<br />
Thread producer = new Thread(new ThreadStart(prod.ThreadRun));<br />
Thread consumer = new Thread(new ThreadStart(cons.ThreadRun));<br />
<br />
try<br />
{<br />
producer.Start( );<br />
consumer.Start( );<br />
<br />
producer.Join( );
consumer.Join( ); <br />
}<br />
catch (ThreadStateException e)<br />
{<br />
Console.WriteLine(e);
result = 1;
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);
result = 1;
}<br />
Environment.ExitCode = result;<br />
<br />
Console.WriteLine("Finished");<br />
Console.ReadLine();<br />
}<br />
}<br />
<br />
public class CellProd<br />
{<br />
Cell cell;
int quantity = 1;
<br />
public CellProd(Cell box, int request)<br />
{<br />
cell = box;
quantity = request;
}<br />
public void ThreadRun( )<br />
{<br />
for(int looper=1; looper<=quantity; looper++)<br />
cell.WriteToCell(looper);
}<br />
}<br />
<br />
public class CellCons<br />
{<br />
Cell cell;
int quantity = 1;
<br />
public CellCons(Cell box, int request)<br />
{<br />
cell = box;
quantity = request;
}<br />
public void ThreadRun( )<br />
{<br />
int valReturned;<br />
for(int looper=1; looper<=quantity; looper++)<br />
valReturned=cell.ReadFromCell( );<br />
}<br />
}<br />
<br />
public class Cell<br />
{<br />
int cellContents;
bool readerFlag = false;
public int ReadFromCell( )<br />
{<br />
lock(this)
{<br />
Console.WriteLine("Enter ReadFromCell()");<br />
if (!readerFlag)<br />
{
try<br />
{<br />
Monitor.Wait(this);<br />
}<br />
catch (SynchronizationLockException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
}<br />
Console.WriteLine("Consume: {0}",cellContents);<br />
readerFlag = false;
Monitor.Pulse(this);
Console.WriteLine("Exit ReadFromCell()");<br />
}
return cellContents;<br />
}<br />
<br />
public void WriteToCell(int n)<br />
{<br />
lock(this)
{<br />
Console.WriteLine("Enter WriteToCell()");<br />
if (readerFlag)<br />
{
try<br />
{<br />
Monitor.Wait(this);
}<br />
catch (SynchronizationLockException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
}<br />
cellContents = n;<br />
Console.WriteLine("Produce: {0}",cellContents);<br />
readerFlag = true;
Monitor.Pulse(this);
Console.WriteLine("Exit WriteToCell()");<br />
}
}<br />
}<br />
|
|
|
|
|
When you call Monitor.Wait() from within the lock, the lock is released and that thread waits for another thread to call Pulse. When that happens, the lock will be re-acquired and the process will continue.
|
|
|
|
|
Ah, I see now. I knew I was missing something, but couldn't quite put my finger on it. Thanks for the tip!
|
|
|
|
|
Hi,
I don't see that crappy setup tool that comes w/ Visual Studio anywhere ? Did I not install it? Am I missing something here ? I have a simple C# app I need to distrubute.
Can someone explain what is involved ? Will it work on WIN98?WIN95?
Thks in advance .
jon
Jon ...
|
|
|
|
|
In my VS.NET (Pro edition) I can find the setup tool under New Project -> Setup and Deployment Projects
Deploying a C# app doesn't require much. Install the .NET framework if it isn't installed and copy the .exe's and .dlls you need to the same directory.
If you use any 3rd party tools/controls refer to their documentation for how you need to deploy their stuff.
Jon E wrote:
Will it work on WIN98?WIN95?
It will work in Win98, .NET isn't supported on Win95
James
Sig code stolen from David Wulff
|
|
|
|
|
What's the equivalent of VB's CreateObject or MFC's CreateDispatch in C#?
Don't want to use references but instead create object by progID.
|
|
|
|
|
Have a look at System.Activator .
Paul
|
|
|
|