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.
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?
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.
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?
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.
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:
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.
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?
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.
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).
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:
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.
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)
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.
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#.....
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.
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,
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.
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]...
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
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".
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" />
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.
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.
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()