Hi Team,
I want to do following Task. Please let me know how should I go for it.
Thanks in advance.
I have a general method and I am getting parameters as "object" type.
No based on object type, I want to do few actions.
Like,
if(objCon.GetType() == typeof(SqlConnection))
{
objCon.Close();
}
But how I will do the "ObjCon.Close" ?......
-Vinod 4 3413
Hi Vinod,
You will have to typecast it to the required object type. In your example,
you would
((SqlConnection) objCon).Close();
Further more, you can also get the various methods that the object supports
by using reflection if it is necessary.
Regds,
Diwakar
"Vinod I" <Vi****@PMAM.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl... Hi Team,
I want to do following Task. Please let me know how should I go for it. Thanks in advance.
I have a general method and I am getting parameters as "object" type. No based on object type, I want to do few actions. Like,
if(objCon.GetType() == typeof(SqlConnection)) {
objCon.Close(); }
But how I will do the "ObjCon.Close" ?......
-Vinod
Cast the variable to the type you need (in this case, SqlConnection). That
will make the methods available.
Should be easy since you are already checking for specific types.
If you want more generic ways of doing this, you'll have to use Reflection
and call the Invoke method of the member you are looking for.
-Rob Teixeira [MVP]
"Vinod I" <Vi****@PMAM.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl... Hi Team,
I want to do following Task. Please let me know how should I go for it. Thanks in advance.
I have a general method and I am getting parameters as "object" type. No based on object type, I want to do few actions. Like,
if(objCon.GetType() == typeof(SqlConnection)) {
objCon.Close(); }
But how I will do the "ObjCon.Close" ?......
-Vinod
Vinod,
You can type cast the object "objCon" as
objCon as SqlConnection, since it satisfies the "if
condition".
So u can do this
(objCon as SqlConnection).Close();
Hope this helps.
Suresh -----Original Message----- Hi Team,
I want to do following Task. Please let me know how
should I go for it.Thanks in advance.
I have a general method and I am getting parameters
as "object" type.No based on object type, I want to do few actions. Like,
if(objCon.GetType() == typeof(SqlConnection)) {
objCon.Close(); }
But how I will do the "ObjCon.Close" ?......
-Vinod
.
Thanks Buddy. That really worked.
"Diwakar Rajagopal" <di***************@in4velocity.com> wrote in message
news:#T**************@TK2MSFTNGP11.phx.gbl... Hi Vinod, You will have to typecast it to the required object type. In your example, you would
((SqlConnection) objCon).Close();
Further more, you can also get the various methods that the object
supports by using reflection if it is necessary.
Regds,
Diwakar "Vinod I" <Vi****@PMAM.com> wrote in message news:%2******************@TK2MSFTNGP10.phx.gbl... Hi Team,
I want to do following Task. Please let me know how should I go for it. Thanks in advance.
I have a general method and I am getting parameters as "object" type. No based on object type, I want to do few actions. Like,
if(objCon.GetType() == typeof(SqlConnection)) {
objCon.Close(); }
But how I will do the "ObjCon.Close" ?......
-Vinod
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jim.brown |
last post by:
Please refer me to the right place if this is the wrong place to post
this question.
I'm looking for an example of calling the Eigenvalue routines of JAMA
from a C++ program. The documentation...
|
by: niftyhawk |
last post by:
Hi,
Can anybody give me a simple example of how to Call Web Services from
Mozilla based Browsers ? I can call web services from IE browser using
web service behavior file, without any problems....
|
by: Julie |
last post by:
I have a situation where I have multiple objects that aren't related in any way
(no base class), but all have a couple of common methods/properties. I'm
looking for a clean way to call a...
|
by: Jesse McGrew |
last post by:
Hi all,
I'm trying to make a plugin DLL for a third-party application, using
VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of
the application, and my actual plugin code...
|
by: Don |
last post by:
This may seem like an odd question, but is it possible to get the name of
the class & function that is calling a function of another class?
e.g.
Public Class CallerName
Public Shared Function...
|
by: John Friedland |
last post by:
My problem: I need to call (from C code) an arbitrary C library
function, but I don't know until runtime what the function name is,
how many parameters are required, and what the parameters are. I...
|
by: ramasubramanian.rahul |
last post by:
hi
i am trying to call some java APIs from c . i use the standatd JNI
calls to load the JVM from a c program and call all java functions by
using a pointer to the jvm which was returned by the JNI...
|
by: cloudy |
last post by:
First at all, i'm sorry, i not good in writing english.
i want to retrieve a string from my applet via Javascript. I use a method named ReadAll.
public String ReadAll(String StrOut, String...
|
by: Ron Ford |
last post by:
K&R has three different versions of qsort, and the ultimate one is supposed
to be like the one in the std library. I'm trying to implement the first,
which is in §4.10.
I think I'm pretty close...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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,...
| |