ka es es en en en en ka ka ka en en en en en en en en en en ka ka ka ka en en en en ka ka en ka en kn en en en en en en en en ur en en en en it en en en en en sv en en en en en en en en en en en en en en en en az en en en en en en en en en en en en en en en en ca en en en en en en en en en en fr en en el en en en en en en en en en en en en en en en en en en en en en en en en en en es de te en zh pl en en en en es en en en en en ka ka ka ka ka ka en en ceb pt en en en en en ceb pt en en zh en en en ja en ceb pt en en en en en ceb en en en ru zh en ja en kn en en en en en en en en en en es es en en en en en en en en en en en en en en en en en de en en en en en
კომენტარები კოდში - The complete C# tutorial
Download PDF + Code samples
Download this entire tutorial as PDF, plus all the code samples, right now!
Code comments & the Task list
Working with Dates & Time
Implicitly typed variables (the var keyword)
LINQ: Query Syntax vs. Method syntax
Filtering data: the Where() method
Sorting data: the OrderBy() & ThenBy() methods
Limiting data: the Take() & Skip() methods
Data transformations: the Select() method
Grouping data: the GroupBy() Method
Working with Culture & Regions
Application Culture & UICulture
Searching with the Regex Class
Search/Replace with the Regex Class
Randomness with the Random class
Starting applications with the Process class
Stepping through the code
Introduction to XML with C#
Reading XML with the XmlReader class
Reading XML with the XmlDocument class
Working with the XmlNode class
Using XPath with the XmlDocument class
Writing XML with the XmlWriter class
Writing XML with the XmlDocument class
Introduction to C# 3.0
Reading and writing files
Manipulating files and directories
File and directory information
A Reflection based settings class
This article is currently in the process of being translated into Georgian (~17% done).
If you are fluent in Georgian, then please help us - just point to any untranslated element (highlighted with a yellow left border - remember that images should have their titles translated as well!) inside the article and click the translation button to get started. Or have a look at the current translation status for the Georgian language.
If you see a translation that you think looks wrong, then please consult the original article to make sure and then use the vote button to let us know about it.
Please help us by translating the following metadata for the article/chapter, if they are not already translated.
If you are not satisfied with the translation of a specific metadata item, you may vote it down - when it reaches a certain negative threshold, it will be removed. Please only submit an altered translation of a metadata item if you have good reasons to do so!
Please login to translate metadata! Already logged in? Please try reloading the page!
Looking for the original article in English?
კოდის წერის დროს, მალევე მიეჩვევით იმ ფაქტს, რომ თითქმის ყველა სიმბოლო და სიტყვა რაღაც მნიშვნელობას ატარებს. მაგალითად, ნახავდით ისეთ საკვანძო სიტყვებს (keywords) როგორიცაა class, namespace, public და ა.შ. ასევე ნახავდით რომ კომპილატორი ყურადღებას აქცევს ამ საკვანძო სიტყვებისა და თვენ მიერ შექმნილი ცვლადების სწორად გამოყენებას. C# საკმაოდ მკაცრი ენაა და კომპილატორი დაგეხმარებათ ყველაფერი ისე გეწეროთ როგორც საჭიროა. თუმცა, ერთ ადგილას მაინც გაქვთ შესაძლებლობა ის წეროთ რაც მოგესურვებათ, ამის საშუალებას კომენტარების ცნება გაძლევთ.
შესაძლებელია კოდში უკვე ნანახი გქონდეთ კომენტარები. იქნება ეს C# თუ სხვა პროგრამირების ენა - კოდში კომენტარების ცნება საკმაოდ უნივერსალურია, მაგრამ მათი ჩაწერის სტილი განსხვავდება, ასე რომ ვნახოთ როგორი სახის კომენტარები გვაქვს C#-ის კოდში.
C#-ში ყველაზე მარტივი კომენტარის ტიპი ერთხაზიანი კომენტარია. როგორც სახელი გვეუბნება ის ერთ ხაზს აქცევს კომენტარად - მოდით ვნახოთ როგორ გამოიყურება ის:
// My comments about the class name could go here...
So that's it: Prefix your lines with two forward slashes (//) and your text goes from something the compiler will check and complain about, to something the compiler completely ignores. And while this only applies to the prefixed line, you are free to do the same on the next line, essentially using single-line comments to make multiple comment lines:
// My comments about the class name could go here...
// Add as many lines as you would like
In case you want to write multiple lines of comments, it might make more sense to use the multi-line comment variant that C# offers. Instead of having to prefix every line, you just enter a start and stop character sequence - everything in between is treated as comments:
My comments about the class name could go here...
Add as many lines of comments as you want
...and use indentation, if you want to!
Use the start sequence of forward-slash-asterisk (/*), write whatever you like, across multiple lines or not, and then end it all with the end sequence of asterisk-forward-slash (*/). In between these markers, you can write whatever you want.
As with pretty much any other programming related subject, whether to use multiple single-line comments or one multi-line comment is often debated. Personally, I use both, for various situations - in the end, it's all up to you!
Documentation Comments (sometimes referred to as XML Documentation Comments) looks like regular comments, but with embedded XML. Just like with regular comments, they come in two forms: Single-line and multi-line. You also write them the same way, but with an extra character. So, single-line XML Documentation Comments uses three forward slashes (///) instead of two, and the multi-line variant gets an extra asterisk added in the start delimiter. Let's see how it looks:
/// The Name of the User.
public string Name { get; set; }
*  The Age of the User.
public string Age { get; set; }
Here you can see both variants - single-line and multi-line. The result is the same, but the first variant tends to be the most commonly used for documentation comments.
Documenting your types and their members with documentation comments is a pretty big subject, and therefore it will be covered more in depth in a later article, but now you know how they look!
Code comments & the Task list
If you're using Visual Studio, you can actually get some help tracking your code comments. In the Task List window (access it from the menu View > Task List) your comments will appear if they use the special, but very simple Task List comment syntax:
//TODO: Change "world" to "universe"
//HACK: Don't try this at home....
int answerToLife = 42;
So if the single-line comment is immediately followed by TODO or HACK, it will appear in the Task List of Visual Studio, like this:
And there are more types - depending on the version of Visual Studio you're using, it will respond to some or all of the following comment tokens:
You can even add your own tokens, if you want to - just follow the steps described in this article.
Code comments are extremely useful in documenting your code or for the purpose of leaving clues to your self or your potential colleagues on how stuff works. As an added benefit, they're great when you need to test something quickly - just copy a line and comment out the original line and you can see how it works now. If you're not happy with the result, you can just delete the new line and uncomment the original line and you're back to where you started.
And don't worry about the end-user snooping through your comments - they are, as already mentioned, completely ignored by the compiler and therefore not in anyway included in your final DLL or EXE file. Code comments are your personal free-space when programming, so use it in any way you want to.
This article has been fully translated into the following languages:
Is your preferred language not on the list? Click here to help us translate this article into your language!