types

Is it bad not to know how to type?

Im about to enter the work force and don't know how to touch type. Is this a bad thing, even though im pretty fast in my own methods? At Least Related, if not Duplicate: Do you use the home row? ...

What is the underlying type of a c++ enum?

This may have been answered elsewhere but I could not find a suitable response. I have this code: enum enumWizardPage { WP_NONE = 0x00, WP_CMDID = 0x01, WP_LEAGUES = 0x02, WP_TEAMS = 0x04, WP_COMP = 0x08, WP_DIVISIONS = 0x10, WP_FORMULAS = 0x20, WP_FINISHED = 0x40, }; Which is legacy and I have...

Dynamic Type Conversion C#

I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer serializer = new XmlSerializer(type); TextWriter tw = new StreamWriter(fileName); serializer.Serialize(tw, obj, ns); ...

Why does F# infer this type?

This is my code: type Cell<'t>(initial : 't) = let mutable v = initial let callbacks = new List<'t -> unit>() member x.register c = callbacks.Add(c) member x.get () = v member x.set v' = if v' <> v then v <- v' for callback in callbacks do callback v' member x.map f = let c...

Any function on the framework with return type overloading?

Had the idea I'd seen at least one. ...

Generic class with restricted Type parameter

I want to create a generic class that takes a type parameter and restrict that parameter to numeric types or more generally to any type upon which the increment operator ++ can be applied. I know I can do the following to restrict to structs but obviously there are structs that aren't numeric types and for which the ++ operator is not s...

Where can I find a list of Powershell .NET Type Accelerators?

In PowerShell you can use [xml] to mean [System.Xml.XmlDocument]. Do you know where I can find a list of these type accelerators? Are these accelerators specific to PowerShell or .NET? ...

Ignoring Version in an assembly-qualified name passed to Type.GetType()

Is it possible to get a Type via Type.GetType() when the assembly-qualified name passed into GetType() specifies a different Version than the version of the DLL that's actually loaded? If so, what is the behavior of GetType()? I want to get a Type from an assembly regardless of what version the assembly is. I have a function which gets ...

Finding the Concrete Type behind an Interface instance

To cut a long story short I have a C# function that performs a task on a given Type that is passed in as an Object instance. All works fine when a class instance is passed in. However, when the object is declared as an interface I'd really like to find the concrete class and perform the action upon that class type. Here is the ubiquitou...

How to convert PowerBASIC Types to VB6 Types?

These types come from the demos for FastCGI Dll Library (with SIGTERM handler) for Windows Web Servers and are written in PowerBASIC. I'm trying to convert them to VB6 (having also discovered how to call a CDECL DLL from VB6). ' Structures TYPE FCGX_STREAM pData AS DWORD ' Pointer to the first byte of ...

How to use the property grid in a form to edit any Type.

I have an App where I'd like to be able to edit any type (font, colour, point etc.) at run time and use any of the .Net default type editors. (e.g., font/ colour picker). Rather than re-invent the wheel, I decided to use the property grid control. If I pass an object of, say font, to the grid, it lists all the fields separately, with n...

Generate Cast type dynamically in C#

Hello.. Please I have a class in c# whose main function is to return the types and objects as dictionary Over a service . Is it possible to cast the Object sents over the WCF service in the front end. I.e using reflection to get the type of an object from the types.ToString() and using the type to cast the objects. NB the Class that ...

Perfomance of TypeCasting

Hi there, is there any measurably performance difference between ((TypeA) obj).method1(); ((TypeA) obj).method2(); ((TypeA) obj).method3(); and var A = (TypeA) obj; A.method1(); A.method2(); A.method3(); when used alot of times? I often see something like if (((TextBox)sender).Text.Contains('.') || ((TextBox)sender).Text.Contain...

C#: Any difference whatsoever between "(subtype)data" and "data as subtype" typecasting?

Assuming I have an instance of an object that I know belongs to a subclass of a certain subtype passed to me through a reference of a supertype in C#, I'm used to seeing typecasting done this Java-like way (Assuming "reference" is of the supertype): if (reference is subtype){ subtype t = (subtype)reference; } But recently I've come ac...

Assign a type to an object at runtime in vb.net or c#

I have an object, o, and a type, T. I'd like to use reflection to change object o to type T at runtime without instantiating it. The equivalent at compile time would be: Dim p as Point = Nothing I know how to use Activator.CreateInstance to create an instance at run time that is equivalent to: Dim p as New Point() But i don't want...

VBScript Type Mismatch

I have a type mismatch in my VBScript script. I know that the value is correct, but not sure why it's coming up. This is the line where the script terminates: WScript.Echo "DNS Server Search Order: " & objNicItem.DNSServerSearchOrder The script requires a file named servers.txt (which has a list of servers in it, I am tesing using my...

Passing a generic collection of objects to a method that requires a collection of the base type

Say I have a method that is expecting a generic collection parameter of a base type, see Test.MethodA(IEnumerable(BaseClass) listA) below. How come when I pass it a collection of a derived type the code wont build? Wouldn't all instances of DerivedClass also be a BaseClass? I could have just created a new List(BaseClass) and passed that...

assign type to variable, use variable with generic static class

I'm working in a C# web service with a generic static class that takes a type. I was wondering why this does not compile: Type type1 = typeof(MySnazzyType); Assert.AreEqual(0, ConnectionPool_Accessor<type1>._pool.Count); It gives this error: The type or namespace name 'type1' could not be found (are you missing a using directive ...

Determine if a type is static

Let's say I have a Type called type. I want to determine if I can do this with my type (without actually doing this to each type): If type is System.Windows.Point then I could do this: Point point1 = new Point(); However if type is System.Environment then this will not fly: Environment environment1 = new Environment(); //wrong So...

Why does my C# array lose type sign information when cast to object?

Investigating a bug, I discovered it was due to this weirdness in c#: sbyte[] foo = new sbyte[10]; object bar = foo; Console.WriteLine("{0} {1} {2} {3}", foo is sbyte[], foo is byte[], bar is sbyte[], bar is byte[]); The output is "True False True True", while I would have expected "bar is byte[]" to return False. Apparently ...