Question : How to convert this VB.NET code to VC# code?

           Private Hardwares As New List(Of CHardware)
            Private Class CHardware
                  Public HardwareType As String
                  Public HardwareIdentities As New List(Of CHardwareSerial)
                  Public SubHardwares As New List(Of CHardware)
                  Public ParentHardware As CHardware
                  Public HtmlMetaInfo As String

                  Public Class CHardwareSerial
                        Public Areas As New List(Of CHardwareSerialArea)
                        Public Class CHardwareSerialArea
                              Public Sub New(ByVal AreaName As String, ByVal Scope As String)
                                    Me.mAreaName = AreaName
                                    Me.Scope = Scope
                                    Me.Regex = New System.Text.RegularExpressions.Regex(Scope)
                              End Sub

                              Public ReadOnly Property AreaName() As String
                                    Get
                                          Return Me.mAreaName
                                    End Get
                              End Property

                              Private mAreaName As String
                              Private Scope As String
                              Public Regex As System.Text.RegularExpressions.Regex
                        End Class
                  End Class

                  Public Function IsMatch(ByVal Request As System.Web.HttpRequest) As Boolean
                        If Me.HardwareIdentities.Count = 0 Then Return False
                        For Each HardwareSerial As CHardwareSerial In Me.HardwareIdentities
                              If HardwareSerial.Areas.Count = 0 Then Continue For
                              Dim bMatchedAllAreas As Boolean = True
                              For Each Area As CHardwareSerial.CHardwareSerialArea In HardwareSerial.Areas
                                    Dim szAreaVal As String = Request.Headers.Item(Area.AreaName)
                                    If szAreaVal Is Nothing Then
                                          szAreaVal = ""
                                    End If
                                    bMatchedAllAreas = bMatchedAllAreas And Area.Regex.IsMatch(szAreaVal)
                              Next
                              If bMatchedAllAreas = True Then
                                    Return True
                              End If
                        Next
                        Return False
                  End Function
            End Class

Answer : How to convert this VB.NET code to VC# code?

here:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
private List Hardwares = new List();
private class CHardware
{
    public string HardwareType;
    public List HardwareIdentities = new List();
    public List SubHardwares = new List();
    public CHardware ParentHardware;
    public string HtmlMetaInfo;
    
    public class CHardwareSerial
    {
        public List Areas = new List();
        public class CHardwareSerialArea
        {
            public CHardwareSerialArea(string AreaName, string Scope)
            {
                this.mAreaName = AreaName;
                this.Scope = Scope;
                this.Regex = new System.Text.RegularExpressions.Regex(Scope);
            }
            
            public string AreaName {
                get { return this.mAreaName; }
            }
            
            private string mAreaName;
            private string Scope;
            public System.Text.RegularExpressions.Regex Regex;
        }
    }
    
    public bool IsMatch(System.Web.HttpRequest Request)
    {
        if (this.HardwareIdentities.Count == 0) return false; 
        foreach (CHardwareSerial HardwareSerial in this.HardwareIdentities) {
            if (HardwareSerial.Areas.Count == 0) continue; 
            bool bMatchedAllAreas = true;
            foreach (CHardwareSerial.CHardwareSerialArea Area in HardwareSerial.Areas) {
                string szAreaVal = Request.Headers.Item(Area.AreaName);
                if (szAreaVal == null) {
                    szAreaVal = "";
                }
                bMatchedAllAreas = bMatchedAllAreas & Area.Regex.IsMatch(szAreaVal);
            }
            if (bMatchedAllAreas == true) {
                return true;
            }
        }
        return false;
    }
}
Random Solutions  
 
programming4us programming4us