Structure Hold Small Number Of Reference Types?

Jun 10, 2009

Is it okay for a structure variable to hold a small number of reference types? I thinks it's fine because the pointers themselves are not that big, regardless of what they're pointing to. But I never did fully figure out the whole heap/stack thing, so I'd like to make sure.

View 6 Replies


ADVERTISEMENT

Structure To Hold 2 Strings?

Nov 29, 2011

I like to create a Structure that could hold 'Yes' or 'No' only; just like a Boolean variable could hold True or False.

View 12 Replies

C# :: Determining Object Equivalence For Value Types, Reference Types And ILists?

Nov 1, 2009

I have a class with a Property called 'Value' which is of type Object.Value can be of any type, a structure, a class, an array, IList etc.My problem is with the setter and determining whether the value has changed or not.This is simple enough for value types, but reference types and lists present a problem.For a class, would you assume that the Equals method has been implemented correctly, or just assume that the value has changed every time the setter is called?If I did assume it's changed, then perhaps I should assume it for value types as well, so that the behaviour is consistent.

View 2 Replies

Generics - List(Of T) - Use It To Hold Items Of Several Types?

Oct 3, 2009

Assuming a base type of "Message"...

[Code]...

I would like to have one collection of Message objects which can be either PhoneMessages or MailMessages, so that I can iterate through the list and deal with each message based on what type it happens to be.

Attempting just to use .Add() fails, saying that I can't add an item of type PhoneMessage to a List(Of Message). Is there some elegant way to accomplish what I'm trying to do? I had thought I could accomplish this with generics, but I think there's a gap in my understanding. If it can be accomplished in .NET 2.0, that would be ideal.

View 4 Replies

Structure Inside Another Structure Receives Null Reference Error?

Jan 5, 2012

Module Module1
Public Structure structure1
Public TRANS() As structure2
End Structure
Public Structure structure2
Public X() As Integer
End Structure
End Module

View 17 Replies

Best Structure To Hold 'array Of Arrays' Type Of Data That's Also Searchable

Mar 4, 2010

I have a database table of company information.It's about 50 records and contains things like company id, company name, address, phone number, shipping rate1, shipping rate2,etc.I want to load that table into a structure that I can quickly search within my code.I want to search by id to find the company, and then use the company's data to update some records.My lazy way has always been to add a listbox for each piece of data, then do an indexof on the id, then access the same index on the other listboxes.[code]

View 6 Replies

Create A List (of My Custom Structure) To Hold Only Unique Items?

Mar 8, 2012

How can I create a list (of my custom structure) to hold only unique items? This list should be created from another list.[code]...

View 5 Replies

.net - Double Or Integer : What To Use With BIG Or SMALL Data Types

Jul 26, 2011

I have a value of: "2.54334881002458E-37" and i keep getting "overflow" exception when i'm using a double.what should i use to make this work?

code snippet:

Dim curries, act, cat As Double
For Each dataRow As DataRow In dt.Rows
curries = dataRow("Activity")

getting the error when i try to assign Activity to curries.but "activity" is a string in the database....

View 4 Replies

Make A Variable Hold A Reference To An Integer?

Mar 16, 2010

Is it possible to make a variable hold a reference to an integer instead of copying its value when using integerVariable = integerValue ?

View 2 Replies

.net - Don't Create Local Variable To Hold The Reference Of The Object?

Nov 17, 2010

How does the GC dispose objects created in the following 2 scenarios?

1)

Private Function DoSomething() As Boolean
Return New DatabaseManager().Insert()
End Function

2)

Private Function DoSomething() As Boolean
Dim mngr As New DatabaseManager()
Return mngr.Insert()
End Function

In Option 1, I don't create local variable to hold the reference of the object. In Option 2, I hold the reference in local variable.What option is better and why? (if any)

View 2 Replies

VS 2010 Get All Types In A Structure?

Jun 27, 2011

Basically I have a system that will take an unknown structure (that should be marked serializable) and attempt to serialize it to a stream. However, before the system will do that, I want to know if there's a way to check every single variable/property to make sure that all the types are serializable.Anyone know a way?

EDIT: For now, I was able to do this:
Private Function IsSerializable(ByVal obj As [Object]) As [Boolean]
If obj.GetType.IsSerializable Then

[code].....

View 5 Replies

C# - Reference Types - See The Actual Reference?

Jan 11, 2012

The difference between reference types and value types is often confusing for beginners due to not understanding what a variable of value type actually holds. We know that:Value types store the actual valueReference types only store the reference to the object

View 4 Replies

Optional Parameters Cannot Have Structure Types?

Jan 12, 2010

I would just like to know why. optional parameters cannot have structure types?

View 4 Replies

Creating A Lot Of Class And Structure Types For A Project?

Oct 12, 2009

Is there any performance hit (or other problem) to creating a lot of class and structure types for a project? I'm not talking about the number of objects existing in-memory during runtime; rather just defining a lot of object types during design time. I find myself making a lot of small classes and structures that are little more than simply packaging a few related variables together.

View 4 Replies

Any Arithmetic Variable That Can Hold A Number Long

Mar 3, 2012

i am reviewing variabes, and just wondering any variables that can be used in math to hold a value this big =)

[Code]...

View 4 Replies

Set Maximum Number Of Characters That A String Can Hold?

Apr 5, 2011

1) Is it possible to set the maximum number of characters that a string can hold?

Just like the following example from VB6:

Dim my_var As String * 10

2) I noticed that Option Base 1 does not exist. I created a table my_table(2) and tried to msgbox the following[code]...

View 8 Replies

VS 2008 Hold A Number That Is 10,000 Characters In Length?

Nov 28, 2009

Is there any container that would hold a number that is 10,000 characters in length? would I have to create one? If so how would I go about doing something like that?

View 5 Replies

Using A Structure Array With Multiple Member Names With 2 Types?

Nov 2, 2009

I am using a structure array with multiple member names with 2 types. My question is can you single out one of the member names and add its total? kinda like this...

HTML Code:
structure structureName
dim a as string
dim b as double
dim c as double

[code].....

View 2 Replies

180 Day Tracker - Count The Number Of Days A Person Is On Hold

Feb 2, 2010

I need to be able to count the number of days a person is on hold. easy enough! However i need to be able to stop the expression when I enter a stop date so it would look like this "start date 1 to today= x amount of days" but i need to be able to add a stop date to end the counter. and if they go down again start date 2 to today and add number of days from start date 1.

View 1 Replies

Copying Reference Types?

Nov 6, 2011

I understand that an array variable contains a reference to an array object - it is a reference type. A string variable is also a reference type.So, if I make a copy of either one, a change to the copy should also change the result I get when I look at the original because both refer to the same object.

View 5 Replies

Copying Reference Types And String

Mar 2, 2010

I understand that an array variable contains a reference to an array object - it is a reference type. string variable is also a reference type. So, if I make a copy of either one, a change to the copy should also change the result I get when I look at the original because both refer to the same object. In the following code, I expected to see "Whoooy" as the result for original and copy for both the array and the string. It works with the array but not the string.

[Code]...

View 5 Replies

Passing Reference Types By Value (ByVal)

Aug 17, 2009

I'm still working on the code in this thread [URL] and as I mentioned in that thread, I thought that passing objects around between methods would probably be bad for performance (perhaps not really noticeably at first but maybe if I did it enough then it could have an impact).

1. When you pass a reference type to a method using ByVal then what is actually 'copied' ? I understand that ByVal copies the object into the local method that you are calling where as ByRef passes a reference to the actual object so you can work with the original object. So when you have a Reference type and you pass this ByVal then does copy the entire object or does it just copy a 'reference' to the object?

2. When working with an object that relates to a 'physical' item, such as a file on disk or a network stream between two connected machines, then what happens when you pass it around between methods (this might be irrelevant depending on the answer to the first question) ? I mean if I have a NetworkStream object that represents the data stream coming from a remote computer, if I then pass that ByVal into another method then does that mean I am still working with the same data stream or a copy of it or what?

View 9 Replies

Types Not Showing Up For Service Reference

May 30, 2012

I'm integrating one of our apps with a third-party provider's web service. I've added the service reference, but when I go to dimension a var as one of their types, the types aren't showing up for me in Intellisense. I'm using VB.NET/VS 2008 on Windows 7 and a 2.0 Framework web site running on local IIS. I have imported System.Web and System.Web.Service in my codebehind. I also made sure to check the "Always generate message contracts" checkbox.Types not showing up for service reference

View 2 Replies

VS 2008 - Values And Reference Types

Oct 29, 2011

Reading a book, the following examples are given regarding value and reference types. This example is noted as a value example. ptY display {x = 10, y = 20}

Dim ptX As New System.Drawing.Point(10, 20)
Dim ptY As New System.Drawing.Point
ptY = ptX
ptX.X = 200
Console.WriteLine(ptY.ToString())

This example is noted as a reference example. objY displays "Hello Test".
Dim objX As New System.Text.StringBuilder("Hello World")
Dim objY As System.Text.StringBuilder
objY = objX
objX.Replace("World", "Test")
Console.WriteLine(objY.ToString())

The idea is simple enough, but I just can not tell the difference between the two. Could someone explain how the heap, the stack and the New keyword play a role in accessing directly and indirectly objects and variables?

View 3 Replies

Finding The Small Integer Number

Aug 14, 2009

i'm dave mark.. im new to vb 2008.. i just have to have some question.. the problem is i have to input 10 integer number then after inputting the 10 number .. it will compute the sum, average and the smallest.. i have no problem with sum and average but in smallest number only... how to get the smallest number>>?

View 1 Replies

VS 2010 Isnot Requires Operands That Have Reference Types?

Mar 4, 2012

First post here so Im sorry if im posting in the wrong place. Im trying to build a simple poker game which requires the program to recognise hands of each players. Luckily there are 3rd party solutions such as pokereval. However my problem comes when i try to convert a C# ported version of pokereval by Keith Rule, into vb.net. The following error shows up referring to the line with the *.

[Code]...

View 4 Replies

Return Values With Reference Arguments Or By Structure?

Jul 10, 2009

In what situtations is it best to use reference arguments to return values?

Sub Example(byref value as integer)
value = 3
End Sub

In what situations is it best to return the value (perhaps in a structure for more complex types)?

Function Example() as integer
return 3
End Function

View 3 Replies

Another Method To Reference The Array And The Member Of The Structure To Get The Data?

Jan 31, 2010

I have problems with array of structures.my structures are like this

structure order
xxxxxxxxxxx
yyyyyyyyyy
zzzzzzzzzzz
end structure

and then I created many array of structures, like this private arrayorder (100) as order

now i need to sort the entire xxxxxx member of the array of the structure with a function, but I dont want to use loops with arrays indexes to access the information. I want to know if there is another method to reference the array and the member of the structure to get the data.

View 2 Replies

VS 2005 Reference A Member Of A Structure By Using A String Variable

Mar 20, 2009

, I was wondering if it was possible to reference a member of a structure by using a string variable. Here's an example of what i'm talking about:

[Code]....

Now, I know that you would usually reference the value in any of the members by using the following (String1 in this case)

[Code]....

View 4 Replies

Create A Small Application That Will Force User To Enter An Even Number?

Oct 5, 2011

I need to create a small application that will force a user to enter an even number but i MUST use a loop. Here's what i've come up with:

Quote:

Dim bynombrepair As Byte
bynombrepair = InputBox("Entrez un nombre pair")
If bynombrepair Mod 2 = 0 Then

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved