Here’s a question the popped in my mind: Is it possible to show only property(ies) based on what the user has passed parameter in the contructor? To make this question more clear, I’ll illustrate a simple class with some properties.
Public Class SampleClass
Dim _ForA as string
Dim _ForB as string
Public ReadOnly Property PropertyA as String
Get
return _ForA
End Get
End Property
Public ReadOnly Property PropertyB as String
Get
return _ForB
End Get
End Property
Public Sub New(SelectProp as string)
End Sub
End Class
If the user will pass A (string) in the constructor only PropertyA is shown and if B is passed then PropertyB will only be shown. Is it possible in .Net?
Here’s another thing. I found this declaration in some code in the internet. Can you explain what is happening in the declaration?
Imports System.Data
#If DBType = "OLEDB" THEN
Imports System.Data.OleDB
#End IF
#If DBType = "SQLClient" THEN
Imports System.Data.SqlClient
#End IF
Thanks.
The name is Conditional Compilation
You can use conditional compilation to select particular sections of code to compile while excluding other sections. For example, you may want to write debugging statements that compare the speed of different approaches to the same programming task, or you may want to localize an application for multiple languages. Conditional compilation statements are designed to run during compile time, not at run time.
You declare a conditional compiler constant in code with the #Const directive, and you denote blocks of code to be conditionally compiled with the #If…Then…#Else directive. For example, to create French and German language versions of the same application from the same source code, you embed platform-specific code segments in #If…Then statements using the predefined constants FrenchVersion and GermanVersion. The following example demonstrates how
Read this
Conditional Compilation