تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
الدرس السادس والأربعون - Preprocessor Directives
#4
#define, #undef

تستخدم لتعريف symbol معين ، مثلاً يمكنك تعريف symbol لل Debug ، او يمكنك تعريف symbol خاص بك بأي اسم ليتم استخدامه لاحقاً ، المثال التالي مثلاص لتعريف Symbol يعني ان هذا الكود يتم عمل Debug له فقط على Mono .



لاحقاً يمكنك كتابة كود بالشكل التالي :

C#:


كود :
#define DEBUG
#define MONO_BUILD
using System;
namespace PreprocessorDirectives
{
class Program
{
static void Main(string[] args)
{
#if MONO_BUILD
Console.WriteLine("Compiling under Mono!");
#else
Console.WriteLine("Compiling under Microsoft .NET");
CHAPTER 12 n INDEXERS, OPERATORS, AND POINTERS 413
#endif
}
}
}


vb.net:


كود :
#Define DEBUG
#Define MONO_BUILD
Imports System
Namespace PreprocessorDirectives
Class Program
Private Shared Sub Main(ByVal args As String())
#If MONO_BUILD Then
Console.WriteLine("Compiling under Mono!")
#Else
Console.WriteLine("Compiling under Microsoft .NET")
CHAPTER
12
Dim INDEXERS As n, OPERATORS As n, [AND] As n
POINTERS
413
#End If
End Sub
End Class
End Namespace


والله الموفق ...
والسلام عليكم ورحمة الله وبركاته .
}}}
تم الشكر بواسطة:


الردود في هذا الموضوع
الدرس السادس والأربعون - Preprocessor Directives - بواسطة Raggi Tech - 14-10-12, 05:08 PM


التنقل السريع :


يقوم بقرائة الموضوع: