C#: The dot operator

This entry is part 13 of 71 in the series C#

The dot operator (.) is used for member access. The dot operator specifies a member of a type or namespace.

For example, the dot operator is used to access specific methods within the .NET Framework class libraries as in line 11 and 12 below.

using System;

namespace Hello
    class Program
        static void Main()
            string name;

            Console.WriteLine("Hello, what is your name?");
            name = Console.ReadLine();
            Console.WriteLine("Your name is " + name);

In our example above, Console is a class under System namespace. We are using 2 member functions or methods namely, WriteLine() and ReadLine().

The member functions or methods of a class are accessed by the dot operator.


Posted in

PHP: String operators

This entry is part 17 of 54 in the series PHP Tutorial

Earlier, we have used .(dot) to join 2 strings together.


$text1 = 'Hello ';
$text2 = $text1 . 'World!'; 

echo "$text2";
echo "\n";

$text3 = 'Upwhere We ';
$text3 .= 'Belong!';  

echo "$text3";
echo "\n";

$num = 3;

echo "Result: " . ($num + 3); 


In the statement $text3 .= ‘Belong!’, the .(dot) here is a unary string operator.

The statement here will add ‘Belong!’ to variable $text3 itself.

PHP: Variables

This entry is part 4 of 54 in the series PHP Tutorial

Sit back and relax.

Let’s not hurry and move to the more complex example.  Sometimes, it is good to just run code written by others.

We now look at how variables are declared in PHP.


$myText = "Happy New Year! "; 
$myNum = 2014;

echo $myText;
echo "The year is ". $myNum;
Try The Code

In PHP, a variable is preceded by a $ sign and declaration is actually not needed.

As in the example above, if you have $myNum = 2014, the PHP parser will interprete $myNum as an integer directly.

The $myText is a string variable as the text Happy New Year! is enclosed in a double quote.

Notice in line 8, there is a .(dot) in the line.  The . in PHP is a string concatenation. It joins a string and an integer or a string to a string together.