So I'll type something like:
Dim cmd As New SqlCommand()(
But for some things, it doesn't like "As New" and wants me to type like:
Dim nod As employeeNode
When do I know when to use "As New" as opposed to not? Intellisense always
sets me straight, but I'd like to understand better.
Thanks,
Ron 3 1264
As New is a shortcut for ...
Dim cmd as SqlCommand = new SqlCommand();
which declares then instantiates a new SqlCommand .. for some things it
doesn't make sense to do this.
Make sense?
Cheers,
Greg
"Ron Cook" <Ro*****@discus sions.microsoft .comwrote in message
news:0D******** *************** ***********@mic rosoft.com...
So I'll type something like:
Dim cmd As New SqlCommand()(
But for some things, it doesn't like "As New" and wants me to type like:
Dim nod As employeeNode
When do I know when to use "As New" as opposed to not? Intellisense
always
sets me straight, but I'd like to understand better.
Thanks,
Ron
Ron Cook wrote:
So I'll type something like:
Dim cmd As New SqlCommand()(
But for some things, it doesn't like "As New" and wants me to type like:
Dim nod As employeeNode
When do I know when to use "As New" as opposed to not? Intellisense always
sets me straight, but I'd like to understand better.
Thanks,
Ron
You cannot use As New if the class doesn't have a public constructor.
Adam Ruth
The other case being you need to use a constructor other than the default,
like:
Dim cmd As New SqlCommand("SEL ECT * FROM MyTable") This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dr Duck |
last post by:
GDay all,
Something seems odd to me....
I wrote a simple C# function
public void bind(ref object a, ref object b, bool atob)
{
if(atob)
b = a;
else
|
by: seesaw |
last post by:
Is it right thing to always avoid using "new" to create objects? What if
after starting the application, then decide which and how many objects to
create? (Seems like under such situation is there no other choice but using
"new")
|
by: Act |
last post by:
Why is it suggested to not define data members as "protected"?
Thanks for help!
|
by: Rv5 |
last post by:
Rookie c++ question, but Ive spent the last 5 years doing Java, where
everytime I created an object I used new. In c++ I can create my objects
without and its confusing me just a little.
I have a class called polynomial. Its a nothing little class right now,
with just int variables, a basic container class. Im using it as I go
through some tutorials, but in this particular tutorial its telling me to do
polynomial *first = new...
|
by: Pedro CLIKEAR |
last post by:
The problem happens when we try to set the password for two different users
with DirectoryEntry.Invoke method.
The first time we use user.Invoke("SetPassword",new object {pwdUsuario});
it works fine!! but when we repeat the same code for the second user it
throws an exception:
mscorlib: System.Reflection.TargetInvocationException: Exception has been
thrown by the target of an invocation
This doesn´t happen if we close the aplication...
| |
by: Maurice Walmsley |
last post by:
I'll avoid tell you how lame I am and get straight to the question...
I need a good expanation to the "ByVal sender As Object, ByVal e As
System.EventArgs" part of;
Public Sub button01_click(ByVal sender As Object, ByVal e As
System.EventArgs)
I dont understand any of that part. ByVal? sender? e?
System.EventArgs? Do you know of any good references explaining what
this stuff is? I'm sure it's different for each routine, and I
|
by: Mochuelo |
last post by:
Hi,
I know what "new" (and "delete") does in C++, which I've used for
years. I have worked with C# for some time, too, but ok, there are
some curious things about "new" in C# that I still don't grab. For
instance, independently on when the garbage collector kicks in, the
following code should make the amount of memory assigned to my
application grow from A to B and from B to C, right? Well, it doesn't.
At point A: 21488 KB.
|
by: Tony Sinclair |
last post by:
I'm just learning C#. I'm writing a program (using Visual C# 2005 on
WinXP) to combine several files into one (HKSplit is a popular
freeware program that does this, but it requires all input and output
to be within one directory, and I want to be able to combine files
from different directories into another directory of my choice).
My program seems to work fine, but I'm wondering about this loop:
for (int i = 0; i < numFiles; i++)
|
by: Lloyd Bonafide |
last post by:
I followed a link to James Kanze's web site in another thread and was
surprised to read this comment by a link to a GC:
"I can't imagine writing C++ without it"
How many of you c.l.c++'ers use one, and in what percentage of your
projects is one used? I have never used one in personal or professional
C++ programming. Am I a holdover to days gone by?
|
by: chrisli |
last post by:
Hello,
i'm trying to make an Application which can get every Calendar entry from a FOREIGN User in Outlook on a Exchange 2003 Server.
At the moment i can only get my own calender entries. But i need to get the Entries from another User.
Here's my actually code:
Dim osession As New MAPI.Session
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |