C# - Default Value Of "value" In Primitive Types

Jun 23, 2009

primitive types (integer, string, etc) are now classes. However to access the value of the class you just use the object name (ex, x=y). It isn't necessary to refer to a property of the class (x.value = y.value).

[Code]...

View 3 Replies


ADVERTISEMENT

Primitive Types - .Net Anding A Byte And A Double?

Aug 1, 2011

during some code conversion from another persons VB.net project to C#, i have come across the following code:

[Code]...

Now m trying to convert this to C#, but im a little confused as to exactly the meaning of this line:

If lbytRelayStateMask And (2 ^ lintCounter) Then It appears there something going on behind the scenes (that ill have to examine further) however before i do i would just like to clarify the result of this if statement. Am i correct in saying if either one of the sub-expressions equals zero then its false, otherwise its true? Sorry, im not too up to speed on VB.net.

View 2 Replies

Specific Method For Getting Non-primitive Types In An Assembly?

Mar 11, 2011

Is there any class or specific method for getting non-primitive types in an assembly? FieldInfo.Gettype() will do for primtive types but what about non-primitive types?

View 3 Replies

Generic BitConverter.GetBytes For Primitive Data Types?

Jan 19, 2012

addressing the need for getting the bytes of an object. But I am wondering if there is an approach to calling BitConverter.GetBytes on a generic type where I know the type is a primitive (Int32, UInt16, etc).

Public Sub Foobar(Of T as Structure)()
Dim x as T 'Assume T is declared as Int32
Dim y() as Byte
y = System.BitConverter.GetBytes(x)
End Sub

The above will throw your usual error:

Overload resolution failed because no accessible 'GetBytes' can be called with these arguments:
'Public Shared Function GetBytes(value As Double) As Byte()': Value of type 'T' cannot be converted to 'Double'.
'Public Shared Function GetBytes(value As Single) As Byte()': Value of type 'T' cannot be converted to 'Single'.

[code]....

One solution I think would work is a large Select Case calling GetType(), but that is horrendously slow (because of boxing) and looks ugly. I would think that since I call my higher level class with a primitive data type for T, that the compiler would be smart enough to figure it out, but I assume I am not providing enough information for it to derive what T's underlying value is at compile time for the invoked instances.

View 6 Replies

C# - From A List<object> , ToString() Them Just When They Are Primitive Types Or Have This Method Overridden??

Feb 15, 2011

Given a list of objects, I'd like to print a string version of them just in case the object.ToString() result is a relevant string.By that I mean I don't want to get things like:

obj.ToString() -> System.Collections.Generic.List`1[MyLib.Dude]
obj.ToString() -> System.Collections.Generic.Dictionary`2[System.Int32,System.DateTime]
obj.ToString() -> System.Byte[]

But I want to get things like:

obj.ToString() -> Hi
obj.ToString() -> 129847.123
obj.ToString() -> Id = 123

What should be the best way to implement this in a method:

Public Sub PrintInterestingStuffOnly(ByVal coolList as Ilist(Of Object))
For Each obj in coolList
'insert solution here

[code].....

View 3 Replies

Extend Primitive Types Such As System.String And System.Int32?

Jul 25, 2010

Is it possible to extend primitive types such as System.String and System.Int32 (IE: integer) in .Net 4 and if so how?

To be more specific, I am aware of the concept of partial classes but this doesnt seem to be the answer. Also I find that System.String is not inheritable and Int32 is a structure.

Lastly I am interested in knowing both a VB.Net and C# answer to the above question.

View 2 Replies

C# - Is String A Primitive Type

Oct 19, 2010

I am curious about the string and primitive types. Article like this says string is primitive type. However second article on MSDN does not list string as primitive type. However when I ran the code provided in second article, it displays String is not Primitive type.

View 8 Replies

Create Our Own Primitive Type?

Oct 31, 2009

there anyway that we can create our own primitive type? let's say we call this

Code:dim test = 4 then test will automatically be an integer right but i wanted this

Code:dim test = 4% and i want test not to be an integer, but a percentage_integer, in other words, my own primitive type. is that possible?

View 4 Replies

Comparisons For A LINQ Except Query Using Primitive Datatypes?

Jan 13, 2012

Anyone have any insight on the Big O notation for comparisons for a LINQ Except query using primitive datatypes? I couldn't find anything on google.

View 3 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

Compare Two Types In Dictionary Of Types .net?

Jun 23, 2012

I need to compare two dictionary values if the types stored are equal, this is what i have

if gettype(Args(key)) = gettype(argtypes(key)) then
'' do something
end if

[Code]....

View 1 Replies

User To Select Just Straight To Default Printer With Its Default Settings

Dec 3, 2011

I need to print the contents of 3 textboxs to default printer. what examples I have found dont seem to work. I was trying the documentprint1 component as i thought it would be easy but cant figure out how to tell it what to print the second part is to print a variable (string) to the printer as well.no need for user to select just straight to default printer with its default settings

View 1 Replies

VS 2010 Combobox Default Value - Display The Name Of The Person Who Is Doing The Selection As The Default?

Nov 25, 2011

I have a combobox which contains a sample of names selected from a table.Currently the default name displayed in the box is the 1st name found in the table. What I would like to do is display the name of the person who is doing the selection as the default. The name is stored in a public variable 'PubName' and I do not want the user to be able to type into the combobox themselves.Is this possible?

View 2 Replies

Own Browser Becoming Default/Editing Internet Default Options?

Jun 9, 2012

I am creating my own browser. I want to make an option...to set as the browser to default.To do that I have to:Write a code which opens html(generally internet) file through my browser(form load event) DoneChange the "open with..." of the .html,.xml.... files Problem I want to change the open with event from my web browser. Actually i want an options form which will ask the user "Do you want to set /Browser name/ to be your default browser?" If yes then it will change the default options of the internet files.

View 5 Replies

"Nominal Storage Allocation" In The Context Of Primitive Data Type Allocation Size?

Jul 30, 2011

Looking at this table describing the data types in VB.One of the columns is labeled "Nominal storage allocation". What does this mean? Why is the word "nominal" here?

View 2 Replies

IDE :: Set Project Default For Winforms Projects S/ Default Modifier For Controls Added To Winforms Is Private

May 28, 2010

Is it possible to set a project default for VB.NET winforms projects so that the default Modifier for controls added to winforms is Private (not Friend)?I know there's a "modifiers" property in the properties window so I can set it for each individual control however I would like to change the project so from now on myself and other developers have to specifically decide to change from friend to private. (Which I would strongly discourage them from doing).I believe there is no way of doing this, but on another forum a while ago someone mentioned it would be possible with an add-in (but didn't name the add-in or where to get it).

View 1 Replies

Getting An Other File Extension As Default Instead Of All Files As Default Extension?

Jun 25, 2009

I am using VB 08 running an openfiledialogue wanting to get the result of the GDS file (*.gds) to be the default extension at the drop down menu instead of All file when the openfiledialogue box opens.

I coded it with:

OpenFileDialogue.Filter = "GDS File(*.gds)|*.gds|All files|*.*"

but the results i get in the open file dialogue box remains as all files being in the drop down menu as the default file extension. How to i set it to ".gds" format?

View 1 Replies

Add Together Two Nullable Types?

Aug 27, 2010

I have: Dim nVar1 As Long?Dim nVar2 As Long?Dim nVarSum As Long?nVar1 = Nothing nVar2 = 5 nVarSum = nVar1 + nVar2 I would prefer the result to end with nVarSum being 5, instead of Nothing. I understand if you add something to an unknown value, you will end up with "somthing + unknown" or x+5 will always equal "x+5" not "5" because you are still carrying around that unknown "x". However, how can I effectively treat an unknown or Nothing as a zero for the purposes of addition in this case?(What is basically happening is that the end user is sending us a data file, this code parses that file and then sums together about 15 fields. If the user leaves those fields blank instead of assigning a zero to them, I need to treat it as if it was a zero for this one addition operation, but all the rest of the code needs to continue seeing it as a Nothing value since the user did not ACTUALLY submit zero... they submitted blank or nothing)

View 3 Replies

C# - .NET - Custom Types Possible?

Apr 5, 2012

In Delphi you can do something like this :

TArray = array[1..3] of byte;
where you can then declare
T2Array = array[1..3] of TArray

[code].....

View 4 Replies

C# - Built-in Types When (not) To Use?

May 26, 2009

C# and VB.NET comes with built in types that maps to the CLR types. Examples are: int (C#) and Integer (VB) maps to System.Int32, long (C#) and Long (VB) maps to System.Int64. What are the best practices for deciding when to use built in types or not to use them (using the System.* structs/classes instead)?

View 7 Replies

Can Nullable Types Be Used

Jun 27, 2012

Can Nullable Types be used in VB.NET? If so, is it possible to have a Nullable Integer that I can use with a field that accepts NULL in SQL Server?

View 4 Replies

Converting Types Between .Net And VB6?

Jan 7, 2010

Converting types between .Net and VB6?

View 2 Replies

Get Drive Types On Hex Value

Feb 20, 2010

Gota class i'm finishing up to hopefully have as a tutorial on here very soon about working with wndproc in a class for drive readings. Trying to build a simple select state ment for drives removed based off there hexvalue placment so far i've found &H1(Cd devices) and it appears &H0(Usb tho not found other devices to test yet)

[Code]...

View 1 Replies

Have Different Types Of Rectangles?

Mar 8, 2010

I am trying to have different types of rectangles. I thought something like this would work, but Rectangle is not a class.

Public Class xRectangle
Inherits Rectangle
End Class

What I wanted this for was to remove a selection rectangle from an existing drawing. I have all of the objects to draw stored in a list and I am trying to remove the selection rectangle without removing the object it is covering.

View 4 Replies

How To Allow Parameters Of Different Types

Jun 11, 2009

I have a function that accepts a list as the parameter and creates a CSV from the passed list.Currently, the List parameter is of type String i.e.Public Function GenerateCSV(ByVal Source As List(Of String)) As String..My question is, is there a way I could modify the parameter such that it accepts a list of any known type i.e either string, integer etc instead of forcing it accept of type string as I have done above?

View 5 Replies

How To Use Nullable Types

Aug 25, 2010

I'm converting an Access VBA app to VB.NET. It has dates defined as variants or objects to handle null values. I thought this would be a great chance to use the Nullable type. But I can't get it to work. Either it is inappropriate for what I am trying to use it for, or I am doing it wrong. Anyone know how to use it? Reader is a SqlDataReader.

[Code]...

I was hoping I didn't have to put a lot of If .. Null statements throughtout the code, but that is my only option unless someone has any other idea.

View 11 Replies

Replace Value Types With Nothing?

Oct 20, 2011

I am writing a vb.net application which calls a webservice method. The webservice method in question accept some 20 parameters, such as (string x, string y, string z.... Integer a, Integer b, Integer c).Its possible that any one of the integers (a b or c) is not purposefully set to a value. However, because Integer is a value type I cant set it to Nothing, thus I default it to -1 when the user has not selected a specific value for those integers. However, the webservice method wants me to pass it Null/Nothing when the user did not initialize those integers (not 0, or -1, it wants Nothing/Null).

How do I give the webservice what it wants short of multiple conditionals, with slightly different calls to the webservice (e.g. if integer a = -1 then call webservice with (x,y,z,Nothing,b,c) etc...)?

View 1 Replies

Use Two Types Of Application In The Same App?

May 27, 2009

So I have a pretty large application. This app communicates with hardware using a RS422 protocol. Now I'm working on the same app, except it will be using TCP/IP to communicate with the hardware. So this is using different code to do this.But I don't want to write two different applications, because that is two apps I would have to keep updated both of them. The apps are the same exept for the way they communicate with the hardware. Now I can limit the change down to 1 form, all the other forms would stay the same.

View 5 Replies

Using Object Types?

Sep 27, 2010

I understand that different data types have different uses, String for text, Integer for numerical ect. However, if the Object type can be used for ALL types and supportive of everthign then why should i worry about using correct data types such as string and integer if i can just use "Object" for them all and it will work.I could do

Dim Test as Object = "John"

or i could do

Dim Test as String = "John"

They both do the same thing; there must be something very important im missing here but can only think of one thing that it could be; Memory Management.I think that by using a type such as object may take up more memory than using string?

View 4 Replies

What Are These Types Of Screens

May 6, 2011

I often use VBA to automate internet explorer and interact with web sites.I can find links on regular URLs I navigate to, fill in forms on them, etc.But I don't know what these types of windows are that come up or how to get a hold of them to click links on them or enter text in their forms if there is any. It comes up then grays out the screen it came from. It looks like its some java popup or something. I'm not interested in the site this is from, its just an example of one to show what I mean. I've been searching and looking but can't figure it out.

View 5 Replies







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