473,667 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Easy question about array

Hello!

As I have understood this it means the following. Correct me if I'm wrong.
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32 a = 0;
Byte b = 0;
int16 c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony

Sep 22 '08 #1
2 1015
On 22 Sep, 17:44, "Tony Johansson" <t.johans...@lo gica.comwrote:
Hello!

As I have understood this it means the following. Correct me if I'm wrong..
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32 *a = 0;
Byte *b = 0;
int16 *c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony
Array is a reference type, which holds a series of reference objects
or value type objects.

to know more http://msdn.microsoft.com/en-us/libr...53(VS.71).aspx

-Cnu
Sep 22 '08 #2
Tony Johansson wrote:
Hello!

As I have understood this it means the following. Correct me if I'm wrong.
You store type objects in the array obj and the first one is refering to
a and the second is refering to b and the third is refering to c.
You store reference types of type object in the array but all of them is
refering to value types(a,b,c)

int32 a = 0;
Byte b = 0;
int16 c = 0;
object[] obj = {a,b,c};

It's the same as saying
object o1 = a;
object o2 = b;
object o3 = c;

//Tony
Yes, that is correct.

To store the values in the array, each value is boxed inside an object
that is allocated on the heap.

--
Göran Andersson
_____
http://www.guffa.com
Sep 22 '08 #3

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

Similar topics

3
1343
by: Captain Nemo | last post by:
Hi I'm trying to build a simple, one-dimensional array of prices, where the key to each element is the product code. So I start by executing a select query "SELECT Code, Price FROM Products", and the results are returned in a two-dimensional array, $data, which I can loop through like this: while (list(, $value) = each($data))
7
2742
by: Tino Lange | last post by:
Hi! I identified a bottleneck in my programs. I just want to "encrypt" data by easy xoring. Ok - that's no encryption at all - I know. But it's hardly readable - and that's enough :-) Just some quick obscurity. It turns out not to be quick at all. I really didn't expect this to be a bottleneck, but it takes quite some time.
5
2346
by: Hamish Dean | last post by:
Hi. I want to pass an array through a function. how do i do this? eg. void SomeFunction(){ int Array; Array = 1; Array = 2; Array = 3;
5
1552
by: Harold Howe | last post by:
Howdy, 1- Are property reads in effect volatile? Or is the compiler allowed to optimize property reads away? ie class foo { public int bar { get { return m_bar;}
18
39991
by: Mike Bartels | last post by:
Hi Everyone! I have two Arrays A and B. Both arrays are byte arrays with 7 bytes each. The contents of array A and B are the same A = {1, 2, 3, 4, 5, 6, 7}; B = {1, 2, 3, 4, 5, 6, 7}; When I do
3
2334
by: Rob Meade | last post by:
Hi all, I have a login page which has username and password fields, a login button, and 2 validation controls (one for each field) - currently I have controls to display to the summary if the items missing etc.all working fine... However, when the user logs in I fire off to a stored procedure, at this point, unless the login is successful I can return up to about 8 different error numbers in a string which I then split out into an...
7
1442
by: jimi_xyz | last post by:
I am kind of new to C sharp; I have a quick question I have multiple text boxes 12 of them to be exact. What I want to do is fill them with values that are in a array of integers. The way I am currently doing this is like this.. input0.Text = Convert.ToString(arr); input1.Text = Convert.ToString(arr); input2.Text = Convert.ToString(arr); input3.Text = Convert.ToString(arr); input4.Text = Convert.ToString(arr);
7
1982
by: David Lowndes | last post by:
I've got a project with a fair bit of mixed C++/CLI calling native code, often passing raw pointers - and I'm worrying that we may have occasions where we don't use pin_ptr when we need to. However, after a few experiments I was unable to compile code (VS2005) that casually tried to do the wrong thing. So, is anyone aware of any common gotchas where you can have code that compiles cleanly (and works in all tests) that's not using...
1
1608
by: paulf.johnson | last post by:
Hi, For some reason, my brain has gone to mush on a couple of things. Any help would be appreciated. I have an array and a field passed into a function (call it $v) which is a string composed of comma sep values. foo = array("one"=>1, "two", "three", "four", "five"); $ex = explode("," $v);
0
8458
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
8366
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
8790
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...
1
8565
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7391
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...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2779
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
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
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.