How to create Shared VB Array Initialisors for NerdDinner

Posted by David A Gibson on Stack Overflow See other posts from Stack Overflow or by David A Gibson
Published on 2009-06-29T12:28:18Z Indexed on 2010/04/25 4:33 UTC
Read the original article Hit count: 385

Filed under:
|
|
|
|

Hello,

I am trying to work my way through the NerdDinner tutorial - and as an exercise I'm converting it to VB as I go. I'm not very far in and after having gotten past the C# Yield statement I'm stuck on Shared VB Array Initialisors.

static IDictionary<string, Regex> countryRegex =
new Dictionary<string, Regex>() {
{ "USA", new Regex("^[2-9]\\d{2}-\\d{3}-\\d{4}$")},
{ "UK", new
Regex("(^1300\\d{6}$)|(^1800|1900|1902\\d{6}$)|(^0[2|3|7|8]{1}[0-
9]{8}$)|(^13\\d{4}$)|(^04\\d{2,3}\\d{6}$)")},
{ "Netherlands", new Regex("(^\\+[0-9]{2}|^\\+[0-
9]{2}\\(0\\)|^\\(\\+[0-9]{2}\\)\\(0\\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\\-
\\s]{10}$)")},

Can anyone please help me write this in VB?

Public Shared countryRegex As IDictionary(Of String, Regex) = New Dictionary(Of String, Regex)() {("USA", New Regex("^[2-9]\\d{2}-\\d{3}-\\d{4}$"))}

This code has an error as it does not accept the String and the Regex as an item for the array.

Thanks

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about shared