473,698 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type cast

Hi,

How do i type cast a type to an array of type,
e.g. IntPtr to IntPtr[] ??

/Peter
Jan 30 '06 #1
2 1447
You cannot simply turn a int into an array of ints, they are different
types.

You can add an int to an array of ints.

int[] manyInts = new int[] {myInt1, myInt2};

"Peter Larsen" <tj******@gmail .com> wrote in message
news:OW******** *****@TK2MSFTNG P14.phx.gbl...
Hi,

How do i type cast a type to an array of type,
e.g. IntPtr to IntPtr[] ??

/Peter

Jan 30 '06 #2
Ok, i think i have to explain this a little bit better :-)
IntPtr poins to an array of structs, chars, floats or other types.

E.g. in some languages, if you have a property s of the type string, you can
simply turn s into an array of chars, s[0].

Or in C++ you can do something like this:

struct MyStruct
int count;
int i[1];
}

MyStruct ms = (MyStruct)myPro perty.
ms->i[count-1] etc.etc.

/Peter

"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:u9******** ******@TK2MSFTN GP09.phx.gbl...
You cannot simply turn a int into an array of ints, they are different
types.

You can add an int to an array of ints.

int[] manyInts = new int[] {myInt1, myInt2};

"Peter Larsen" <tj******@gmail .com> wrote in message
news:OW******** *****@TK2MSFTNG P14.phx.gbl...
Hi,

How do i type cast a type to an array of type,
e.g. IntPtr to IntPtr[] ??

/Peter


Jan 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
547
by: Richard Lee | last post by:
Hi, I have a question when I do a data type cast. the common way when we do a cast, is we know the type we want to cast to, i.e. we want to cast object to string, object xyz = "question"; (string)xyz; now we only have a type object of System.String type
5
8722
by: verec | last post by:
I just do not understand this error. Am I misusing dynamic_cast ? What I want to do is to have a single template construct (with no optional argument) so that it works for whatever T I want to use it with. Now, if that T happens to be some subclass of a known base class (object, in this case), I want to perform some extra stuff ... I've read Faq#35, and the most natural solution would have
4
14127
by: NotYetaNurd | last post by:
Hi all, I read that delegates are type safe and Functional pointers are not!!... in this context what does type safety mean? can anyone of you throw some light on it regards, ...
2
833
by: Dave Leach | last post by:
I am writing a Windows MDI application in C#. I would like to cast an object to a specific type. I know that the object is of a compatible type. The code below shows what I would like to do, but does not compile, where the cast "(c.ItemType)" produces the error "type or namespace could not be found". I know that each control "c" has a public property "ItemType" which returns a Type foreach ( MyComboBox c in cbControls name =...
2
9220
by: Fred Zolar | last post by:
Anyone know how to cast an object to the type stored in a System.Type variable? I need to cast m_oValue to an int, bool, ect... based on the variable Type. public class TestClass { private object m_oValue; public System.Type Type;
3
21218
by: mra | last post by:
I want to cast an object that I have created from a typename to the corresponding type. Can anycone tell me how to do this? Example: //Here, Create the object of type "MyClass" object obj=Activator.CreateInstance(strAssemblyName, "MyClass"); //Now, I want to do something like ((MyClass)obj).Method //Can I do this?
7
11942
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return "DirectoryEntry" objects within the path that I specify (either using the DirectoryEnrtry.Children or using the DirectorySearcher class) and all started well and dandy! Now the problem; some of the properties of the DirectoryEntry objects being...
16
11267
by: Martin Jørgensen | last post by:
Hi, Short question: Any particular reason for why I'm getting a warning here: (cast from function call of type int to non-matching type double) xdouble = (double)rand()/(double)RAND_MAX;
14
18743
by: budy_ludy | last post by:
Hi All, I am new to vb .net, I have an ArrayList and i store class objects in it, and later i want to retrieve each ArrayList items and type cast to the class, How can it be done ? I used CType for casting but it is throwing exception.
7
3948
by: * Tong * | last post by:
Hi, I couldn't figure out how to properly type cast in this case: $ cat -n type_cast.c 1 #include <stdio.h> 2 3 typedef unsigned char Byte; 4 typedef signed char Small_Int; 5
0
8676
marktang
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...
0
8608
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,...
0
9029
jinu1996
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...
0
7734
agi2029
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...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
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...
1
3051
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
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.