Quantcast
Channel: Microsoft "Roslyn" CTP forum
Viewing all articles
Browse latest Browse all 504

Use Roslyn to Get Type for CollectionInitializer in Visual Basic

$
0
0
Is there an API that gets the type of a CollectionInitializer? I can call GetTypeInfo to get the type of an Expression or identifier or NumericLiteralExpression and for one element of a CollectionInitializer but not the type Roslyn would infer.

SemanticModel.GetTypeInfo(CollectionInitializer.Initializers(0)).Type

For example Dim I = {1,2.6} should yield a type of Double but using the code above I would get Integer.

I could run a loop and look at each element and then try to figure out what is the correct type but Roslyn knows, how do I get it to tell me?


Viewing all articles
Browse latest Browse all 504

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>