a new coding style which I came across
-
Hi, I am completely new to .NET 3.5.I came across a code in vb.net which I am not able to understand. Below is the code <flags()> Public Enum ModemStatusBits ClearToSendOn = &H10 DataSetReadyOn = &H20 End Enum <structlayout(layoutkind.sequential,pack:> Private Structure DCB Public DCBlength As Integer Public BaudRate As Integer Public Bits1 As Integer End Structure <dllimport("kernel32.dll")> Private Shared Function WaitForSingleObject( _ ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer End Function here what does he mean by putting something in <> before enum,struct,Function Thanks in advance
-
Hi, I am completely new to .NET 3.5.I came across a code in vb.net which I am not able to understand. Below is the code <flags()> Public Enum ModemStatusBits ClearToSendOn = &H10 DataSetReadyOn = &H20 End Enum <structlayout(layoutkind.sequential,pack:> Private Structure DCB Public DCBlength As Integer Public BaudRate As Integer Public Bits1 As Integer End Structure <dllimport("kernel32.dll")> Private Shared Function WaitForSingleObject( _ ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer End Function here what does he mean by putting something in <> before enum,struct,Function Thanks in advance
These are called attributes, this not something very new , the code above seems to use a native windows API (Windows API can be considered as functions provided by OS , to be able to program the OS), This Windows API are present in the dll files Kernel32.dll , GDI32.dll, etc , so in above code we are using attribute "<dllimport("kernel32.dll")>" to tell the compiler that we want to use a windows function WaitForSingleObject() which is present in Kernel32.dll , in the same way we want the compiler to allocate the memory in sequential order hence use an attribute <structlayout(layoutkind.sequential,pack:> (the reason for this sequential allocation is a different topic , let me know if you want details regarding the reason , for now I will skip it :)) Hope this make things clear, let me know if you need further information
-Regards Bharat Jain bharat.jain.nagpur@gmail.com
-
These are called attributes, this not something very new , the code above seems to use a native windows API (Windows API can be considered as functions provided by OS , to be able to program the OS), This Windows API are present in the dll files Kernel32.dll , GDI32.dll, etc , so in above code we are using attribute "<dllimport("kernel32.dll")>" to tell the compiler that we want to use a windows function WaitForSingleObject() which is present in Kernel32.dll , in the same way we want the compiler to allocate the memory in sequential order hence use an attribute <structlayout(layoutkind.sequential,pack:> (the reason for this sequential allocation is a different topic , let me know if you want details regarding the reason , for now I will skip it :)) Hope this make things clear, let me know if you need further information
-Regards Bharat Jain bharat.jain.nagpur@gmail.com
Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot
-
Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot
-
Hi Bharat Thanks a lot for replying so soon. I want to know in detail about this feature attributes.How to use that and what are the advantages. If you dont mind can you give a url or some tutorial describing about this. My mail id is poornachandarv_004@hotmail.com Thanks a lot
Ya that is true the best way to learn is MSDN documents , also use the intellisense in Visual Studios , it would be too hard to mention about all attributes , but if you have specific doubts , may be i can help
-Regards Bharat Jain bharat.jain.nagpur@gmail.com