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


ADVERTISEMENT

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

"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

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

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

Create A Function Which Have Either 1 Parameter With A String As Data Type Or 2 Parameters With Double As Data Type?

Jun 11, 2012

I need to create a function which have either 1 parameter with a string as data type or 2 parameters with double as data type.Something like the substring method.

View 2 Replies

VS 2005 List(of T) - Create A List To Hold More Than One Control Type Or Create A List For Each Control Type?

Jan 20, 2011

If I create a list for a TextBox:

[Code]....

I am able to only add controls that are of type TextBox. My question to you is, can I create a List to hold more than one control type or do I have to create a list for each control type?

View 8 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# - 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

Could Not Create Instance Of Type

Jun 5, 2011

I have created a UserControl Popup window and called that xaml file into another file. Imported the namespace.When I am trying to build this project an error at this below given code:

<Popup x:Name="POP" IsOpen="False" PlacementTarget="{Binding}" Placement="Center" AllowsTransparency="True">
<a:PopUpWindow x:Name="pp" />
</Popup>

Error at

<a:PopUpWindow x:Name="pp" />

Could not create an instance of type 'PopUpWindow'.

View 1 Replies

Create Something 'OF' A Variable's Type?

Sep 17, 2009

I have some code like:

Lookup(Of String)("Testing")
Lookup(Of Integer)("Testing")

And both of those Lookups work great. What I'm trying to is call the appropriate LookUp based on the type of another variable. Something that would look like...

Lookup(Of GetType(MyStringVariable))("Testing")

I've tried to Google this but I'm having a hard time coming up with an appropriate search.

View 4 Replies

.net - Create A New System.String Type With Other Name?

Jun 23, 2011

I try to describe my problem step by step because I do not know how to say it in correct programming terms.

When I use a System.String type, I do the following:

Declare the type: Dim Str1 as String
Assign its value: Str1 = "This is a string"

I want to create a new type that just like the System.String type but in different name. For example, I want to create a UrlString type for string like this:

Declare the type: Dim Str2 as UrlString
Assign its value: Str2 = "http://www.example.com"

My question is: How do I create the UrlString type?

The reason: I want to create the UrlString type to help me to identify the value of the content. For example, UrlString type means the string is in url format, PhoneString means the string is in phone format, CreditCardString type means the string is in credit card format and so on.

Class UrlString
Private ReadOnly value As String
Public Sub New(ByVal value As String)

[Code].....

View 1 Replies

Asp.net - Unable To Create Type - PageAdapter?

Aug 22, 2011

Following this tutorial: http:[url].....It works in a test project of mine, but in my production project I get the following error: Server Error in '/products' Application.

Unable to create type 'Photocreator.ThemedPageAdapter'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Unable to create type 'Photocreator.ThemedPageAdapter'.

Source Error: An unhandled exception was generated during the execution of the current web request.Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Unable to create type 'Photocreator.ThemedPageAdapter'.]
System.Web.Configuration.HttpCapabilitiesBase.GetAdapter(Control control) +889
System.Web.UI.Control.ResolveAdapter() +214[code].....

This appears on all pages, both projects are using framework V4.

View 1 Replies

Create A Constant Of Type Date?

Jan 19, 2009

I want to create a constant of type date and assign it a list of 3 date. How can I assign a list of values to a constant. const dates as date=#1/1/2009#, #5/1/2009#.....

View 7 Replies

Create A New Instance Of A Type Given As Parameter?

Mar 7, 2010

I've searched for an answer and found some c#-examples, but could not get this running in vb.net:

I thought of something like the following[code]...

I know, I can create a new instance with the Activator.Create... methods, but how to create an array of this type or just declare a new variable?

View 3 Replies

Create A Program In The Form Type?

Jul 3, 2009

im supposed to create a program in the form type. its supposed to ask the user for a number so i created a textbox for the entry for the number in the form and a button to execute the program. then the program prints a number of "$$$$$" dollar signs as the entered number. furthermore, only upto 5 "$$$$$" sings should be in a row. oh and i have to use the for-loop for this. i used to be do this when i did qbasic but i have completely forgotten the codes and syntax, etc.

View 11 Replies

Create A Safe Type Programme

Mar 3, 2010

im trying to create a safe type programme on visual basic, which has a set combination button which when first clicked opens up a box to allow a password to be entered, once entered the safe is locked until you enter the password and push a button to try the key,

View 1 Replies

Create A Specific Type Of Priorityqueue?

Mar 5, 2010

I want a priority queue that takes two or more entries and sorts by the first one. I already have a priority queue from some programmer named ookii. I had another one and tried that too. Both of them only take one entry, and that just seems useless to me.

Both of them are classes that say like, Dim pq new PriorityQueue(of T)You see, that of T is one element. I don't know what to do to make 2 or more linked elements that can be easily called from existing variables and stuck in a queue sorted by the first element. Basically what I'm used to using is like,Dim sl as new SortedList(thekey,thevalue)When i put things in there, I know what's going on at least.I don't have the experience required to create my own class unless you can walk me through what I need to alter in some other class. I barely know how to go to references and double-click a .dll file that someone else made so I can use functions from it.

I thought to put an array in the "of T" part of the priority queue I have already. But then I'm dimming a whole array every time I want a new entry to the queue. So I want like, a vector? Or some other multi-part entry for the "of T". Two "of T" parts would be ideal because I worked with Sortedlists well already.

View 10 Replies

Create An Array Size And Type Of Another?

Jul 6, 2010

I want to write an extension method that works with all kinds of arrays (Integer, String, Decimal, ...). It returns an array of the same type and size as the input parameter array.[code]...

View 1 Replies

Create New Array Of Parameter Type?

Jan 4, 2011

I'm trying to create a function to parse out all values in a multidimensional Array with all but one dimension given. The details are not relevant, but for this function I need to return an one-dimensional Array containing values of the same type the original multidimensional Array has.To pass any Array with any dimension to my function, I declared the type of this parameter as Array. However, how would I create a new Array of that specific type (e.g. Integer)?Currently I have the following code:

Function GetRow(ByVal arr As Array) As Array
Dim result As (...) 'This should be Integer() if arr contains Integers, etc.
Return result

[code].....

View 1 Replies

Create Thumb For Xxx Type File?

Jan 18, 2012

how can i create thumb for my xxx type file as jpeg files or psd files in windows because they have a separate thumb for ever a file

View 7 Replies

Forms :: How To Create New Variable Of Name Type

Dec 3, 2009

My app has a group of forms that do a specific work in different ways. I want to create a new variable of a form when I want with its name. So, I want a Function in this form :
Public Function GetNew (byref f as form ) as form
That give a form name and return a variable of that type. In other words, it must work as "dim f1 as new formx".

View 4 Replies

How To Create Different Type Of Shapes Of Forms

Mar 20, 2011

I want to create a Windows form application in VB.NET 2008, and I want to create a circle-shaped window. How can I do it?

View 4 Replies

How To Create New Server Control Type

Jun 19, 2012

I'm trying to create a new server control type in ASP.NET. This control would put a RequiredFieldValidator into a certain place. My class inherits from the WebControl class and it has a ControlID property which is the ID of a given control. The RequiredFieldValidator will be generated near the control with the given ControlID. However, the value of ControlID is nothing. In what events can I successfully use this property?

Public Class MyControl
Inherits WebControl
'...
Protected Property ControlID As String
Protected Property IsLinkedBrother As Boolean = False
[Code] .....

But ControlID is Nothing for some reason and the event throws an exception. ControlID is never changed after initialization and it is initialized this way:
<MyControl runat="server" ID="IDValue" ControlID="ControlIDValue" EnableCliendScript="true" CssClass="Whatever" Display="Dynamic" />

View 1 Replies

Re-create Type Of Data Communication?

Aug 20, 2010

I am re-creating a program that was made in vb6. The vb6 program used winsockets for networking. It could host up to 70 clients and there would be constant communication back and fourth. I have just recently switched to using .NET... (Huge Change) more specifically Visual Studio 2010 express (for now). asically, in effort to re-create this type of data communication I have run into a road block.

[Code]...

View 2 Replies

VS 2008 Create New Type To Add To A List?

Dec 24, 2009

When you use List(Of ) you can add different data types to that list, and a while back I remember JM told me to make a new type to list or something and I was wondering how to do that. I want to be able to make a list that has a large amount of text and each item is named so I can gain easy access to that item.

View 1 Replies

VS 2010 - How To Create New Object Type

Oct 26, 2009

I don't know if I stated what I mean in the subject correctly, but I'm making a parsing engine similar to XML so I can implement it in my programs. What I need to know is how to make a new thing like how with XML you can declare a new XMLDocument, like
Dim XDoc as new XDocument
OR:
Dim NPoint as New Point(10,35)

With my parsing engine, I'll have a document type called EDocument and I want to be able to declare string as an EDocument like this
Dim MyDoc as New EDocument()

View 7 Replies







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