c# - assign type to variable, use variable with generic static class -


I am working with a normal static class in a C # web service which takes one type I was thinking That's why it does not compile:

  type1 = typeof (MySnazzyType); Confirm. Eraquall (0, Connectionpool_assore . Pool_ount);  

This returns the error:

Type or name space name 'type1' could not be found (Do not you remember the use directory or assembly reference ?)

And when I hover over the type1 in that second line of code, "type or namespace name is expected". Well, type 1 is one type! This is a type of variable type ! It also does not work if I do:

  type1 = typeof (MySnazzyType); Confirm. EureLL (0, ConnectionPool_Assessor & lt; Typef (Type1) & gt; ._ pool.Count);  

I was hoping to allocate different types of type variables and simply use those typing, which, instead of typing, Examine the general static classes. > Type Messeny every time I get stuck with any idea, or I'm doing:

  Assert.AreEqual (0, ConnectionPool_Accessor . Pool .ount);  

Edit: To clarify, MySnazzyType is not a normal class, and neither It comes from someone generic class is the only general category here ConnectionPool_Accessor .

Thank you for Powell's comment "Basically, your problem is that C # is a statically typed language", now I know that ruby ​​has spoiled me;)

First of all, ReSharper is actually true. It is not type , it is assumed to be an variable , it is a variable that captures the reflection object which matches one type, but this is not enough .

& lt; ...> Between the bracket, you have to type a type of name, not the name of any other identifier.

You can create generic objects through reflection, however, and can access your properties, even static, so that you can rewrite the code to do this However, have you considered the NUIT 2.5?

From the latest release notes, it appears that the unit test classes can now be generic, and you can specify on test class with one attribute that can test it. / P>

This will allow you to type something like this (note, I did not test it, I only saw the names of the new attributes in the document):

  [TestFeactions (Typf (MySnagy Type)) [Testfessescence (MyFusSnaszy Type)) Public Class Test & lt; T & gt; {[Test] Public Zero PoolCount_IsZero () {Assert.AreEqual (0, ConnectionPool_Accessor  ._ pool.Count); }}  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -