Nakov.com

Thoughts on Software Engineering

  • About
  • Books
  • Courses
  • Videos
  • Presentations
  • Research
  • Publications
  • Others
  • Contacts
  • RSS Feed
  • Home

Categories

  • .net (81)
  • blog (330)
  • bulgarian (203)
  • career (21)
  • contests (28)
  • courses (64)
  • english (131)
  • HTML5 (6)
  • java (44)
  • seminars (81)
  • НЛП (7)
  • предприемачество (3)

Networked Blogs

Follow this blog

Recent Posts

  • Представяне на NASA Space Apps Challenge на 2 април 2013
  • Как да презентираме вдъхновяващо с майсторлък? Мурафетите на Наков
  • Пролетен прием в софтуерната академия: 500 нови студента от април
  • Безплатен курс “Бизнес умения за софтуерни инженери” – от 27 март
  • 580 продължават безплатното си обучение в софтуерната академия след изпитите по CSS и C# част 2

Partners

Intro C# Programming Book by Svetlin Nakov
Telerik Academy

My Projects

  • GWT Advanced Table
  • Internet Programming with Java Book
  • Intro C# Programming Book
  • Intro Java Programming Book
  • Java For Digitally Signing Documents In Web Book
  • Programming for .NET Framework Book
  • Software University

Useful Links

  • Bulgarian Association of Software Developers (BASD)
  • Free Java and Java EE Course
  • NLP Club Bulgaria
  • Stefan Kanev's Blog
  • Telerik Academy
  • Telerik Kids Academy
  • Telerik School Academy

Tags

AJAX ASP.NET C# CSS development HTML Java JavaScript NET Programming Software SQL telerik Академия на Телерик Академия на Телерик за ученици академия академия за софтуерни инженери безплатен курс безплатни курсове безплатни уроци безплатно безплатно обучение курс обучение програмиране разработка на софтуер семинар софтуерна академия състезание телерик

Most Viewed Posts

  • Rejected a Program Manager Position at Microsoft Dublin – My Successful Interview at Microsoft
  • Svetlin Nakov – About Me
  • Innovations in Software Тest Automation – конференция за QA инженери – 25.11.2011
  • Online AES Encryption Tool
  • Disable Certificate Validation in Java SSL Connections
  • My Interview at Google in Zurich
  • Native SQL Queries in Entity Framework
  • JAX-RS, @Path, @PathParam and Optional Parameters
  • Svetlin Nakov – Books
  • NHibernate Lazy Loading BLOB column

Author: Svetlin Nakov

November 20, 2012

  • Svejo.net
  • Tweet

Free Public Speaking Event @ Telerik Academy (Toastmasters Club Sofia), 27-November-2012

We are happy to announce an event, especially organized for those of you who want to improve their public speaking skills (in English). A demonstrational meeting held by the Toastmasters Club Sofia will take place in our “Light” training hall on November, 27th 2012 (Tuesday) @18:30.

How Toastmasters Public Speaking Workshops Work?

A Toastmasters meeting is a learn-by-doing workshop with a no-pressure atmosphere. There is no instructor. Instead, members evaluate one another’s presentations. This feedback process is a key part of the program’s success. Meeting participants give prepared speeches, evaluation speeches as well as impromptu talks on assigned topics, and develop skills related to timekeeping, grammar and parliamentary procedure.

A typical meeting of Sofia Toastmasters consists of three prepared speeches and five impromptu speeches as well as a lot of evaluation and feedback for the speakers. It takes up to two hours. As it is an international organization the official language is English.

If you are eager to give a presentation, test your public speaking skills and receive a friendly feedback, or you prefer to listen to the speakers, share your opinion and gain some experience, you are welcome to join the session. As usual, admission is free and only a registration is required.

About Toastmasters International

Toastmasters International is a club in which people train and practice their presentation and leadership skills. There are Toastmasters clubs in 116 countries and the global membership currently is over 200 000 people. Watch a video of a regular meeting on “Public Speaking” and learn more about the initiative: http://bit.ly/Q4SrFp.

Please bear in mind that the seats available for next Tuesday are limited. We will, however, try to organize such meeting on regular basis (twice a month).

Antonia Iordanova, Теодора Желязкова, Joanna Georgieva liked this post

Tags: English, public speaking, seminar, Toastmasters, Toastmasters Club Sofia, Toastmasters International, workshop

Previews (150,428), Views (2,777), Comments (5)

Author: Svetlin Nakov

October 4, 2012

  • Svejo.net
  • Tweet

Cloud Platforms for .NET Developers – My Talk at DevReach 2012

DevReach 2012 - Nakov's TalkI was invited to give a talk at DevReach 2012 – the largest developer conference in South-Eastern Europe. DevReach 2012 will host 60+ sessions in 6 parallel tracks (Web, Mobile, Cloud, Architecture, Agile and Testing) in 2 days. It will be held in Sofia (4-5 October) and is organized by Telerik and Martin Kulov.

My Talk at DevReach 2012: Public .NET Clouds

In the last year I got solid experience about cloud development, public cloud platforms, cloud database, storage and other cloud services. I organized a practical cloud development course at Telerik Academy last year. I teach C# and JavaScript and I focus on .NET and HTML5 platforms, so I am notably interested in .NET clouds. I have researched many clouds that claim to provide .NET cloud platform but most of them do not really provide .NET PaaS solution, but just IaaS cloud hosting, which is different. My lecture and demonstration will be about the public .NET PaaS platforms: “Public Cloud Platforms for .NET Developers”.

.NET Public Clouds – Video


Public .NET Clouds – Presentation


.NET Public Clouds – Downloads

  • The .NET Clouds presentation: Nakov-Public.NET-Clouds-DevReach-2012.pptx
  • The demos (ASP.NET MVC app deployed on AppHarbor and Uhuru AppCloud): Nakov-.NET-Clouds-DevReach-Demo-MessagesWebApp.rar

Public Cloud Platforms for .NET Developers

Public clouds platforms are rapidly growing and many businesses move partially or fully their IT infrastructure to the cloud. The big players like Microsoft, Google, Oracle and Amazon operate their own public cloud platforms while the smaller players provide cloud services and PaaS platforms and on top of the larger. What about the .NET developers and the cloud?

In this talk the speaker will introduce the public .NET clouds and will compare the leading .NET PaaS clouds: Windows Azure, AppHarbor, Uhuru and AWS Elastic Beanstalk for .NET. The .NET public clouds will be compared in terms of architecture, programming model, pricing, development stack, available services, deployment model and tools for administration and monitoring. A live demo will show how to deploy and run a typical .NET application (based on ASP.NET MVC and MS SQL Server) in AppHarbor and Uhuru.

I will not show a demo about Amazon AWS and Beanstalk for .NET as well as about Azure. Azure and AWS will be well covered at DevReach 2012 and it will be more practical to demonstrate the other .NET cloud platforms: AppHarbor and Uhuru. In fact most public clouds like Heroku, Engineyard, OpenShift and CloudBees, Oracle and VMware do not support .NET as a development and deployment stack. You have two options: use IaaS and handle the entire architecture and deployment yourself or use some of the four main players at the .NET public cloud market (as of September 2012):

  • Windows Azure and SQL Azure – the Microsoft’s .NET cloud which requires to adopt and partially rewrite your application to run in the cloud. Many developers avoid it due to high prices and the differences in the platform.
  • Amazon AWS Beanstalk for .NET – the Amazon AWS cloud adapted for .NET developers. It is in fact a mix of IaaS service well suited for .NET development and deployments and Amazon’s PaaS services. Many developers prefer it, but I personally don’t like Amazon because the charge for resources which are not allocated and not in use.
  • AppHarbor – my favorite .NET public cloud. It has free version for testing and deployment of small applications and is really made easy for developers, pure .NET platform and APIs, scalable, with many plugin services.
  • Uhuru – the other public .NET cloud which has free version for testing and small .NET applications. It is based on a solid general purpose cloud platform, the CloudFoundry, adapted to support Windows and .NET.

DevReach 2012 – New PowerPoint Template

At each large conference where I am speaker, I need to fix and improve the PowerPoint template that the organizers send to the speakers for the conference slides. I don’t know why but seems like designers are hired to make good looking slides and their design does not cover all use cases for typical developer conference slides (e.g. consistent colors, layout showing source code, layout for titles slides, layout for normal slides, layout for the questions slide).

For all DevReach 2012 speakers I provide my fixed version of the PowerPoint (PPTX) template (with my presentation included in it):

  • Nakov-Public.NET-Clouds-DevReach-2012.pptx

The improvements over the original DevReach PPTX template are:

  • 1st, 2nd, 3rd, … level of text – with similar colors like the original design
  • Fixed the “Title Slide” slide layout
  • Fixed the “Title and Content” slide layout
  • Fixed all broken colors
  • Created a source code template
Sevgin Hashimov, Теодора Желязкова, Yordan Todorov, Благовест Клисарски, Tihomir Iliev, Alexander Lazarov liked this post

Tags: .NET cloud, .NET cloud platform, AppHarbor, ASP.NET, aws, azure, Beanstalk for .NET, cloud, cloud plaftorms, developer conference, development, DevReach, DevReach 2012, NET, PaaS, PowerPoint template, PPTX template, public .NET cloud, sofia, SQL Server, Uhuru

Previews (50,841), Views (783), Comments (4)

Author: Svetlin Nakov

July 6, 2012

  • Svejo.net
  • Tweet

Креативност и мисловни карти в управлението на проекти – 9 юли

PMI.bg - logoPMI Bulgaria (българската секция на Международния институт по управление на проекти PMI) организира “16th PMI Bulgaria Chapter Members Meeting” на тема “Creativity and Mind Maps in Project Management” на 9 юли (понеделник) от 18:30 часа в Софтуерната академия на Телерик (зала Ентерпрайс).

Програма на обучението

Семинарите на PMI Bulgaria по принцип са за членовете на PMI. Ако се интересувате от управление на проекти, можете да станете член на PMI Bulgaria на място на събитието.

  • 18:30 – 19:00 – Регистрация (за нови членове на PMI си носете снимка)
  • 19:00 – 19:45 – Креативност и мисловни карти в управлението на проекти (част I)
  • 19:45 – 20:00 – Почивка
  • 20:00 – 20:45 – Креативност и мисловни карти в управлението на проекти (част II)
  • 20:45 – 21:30 – Дискусия, представяне на нови членове, коктейл

Лектор на семинара ще е Антон Ценов от Mindmapping.bg – лицензиран инструктор от ThinkBuzan – организацията на Тони Бюзан (изобретателят на мисловните карти).

Регистрация за PMI семинара

За участие в обучението по управление на проекти с използване на мисловни карти, трябва да се регистрирате най-късно до 8 юли от формата за регистрация.

Tags: mind maps, Mindmapping.bg, PMI, PMI Bulgaria, PMI България, project management, seminar, Антон Ценов, мисловни карти, обучение, семинар, софтуерна академия, тренинг, управление на проекти

Previews (54,980), Views (1,102), Comments (6)

Author: Svetlin Nakov

May 28, 2012

  • Svejo.net
  • Tweet

10+ High-Quality Free WordPress Themes

High-quality free WordPress themesI often create simple Web sites and in most cases I use WordPress as a CMS (content management system). If the customer does not need something very special and unique, I prefer to use proven free WordPress themes or paid themes from Theme Forest (if I have non-zero budget). This works well for small Web sites, saves time and money, makes the customers happy and the support later is straightforward. WordPress does its job well. It is great for building small Web sites and blogs and it is SEO-friendly (after very few customizations) and has a lot of plugins and extensions, including reliable spam protection (thanks to Akismet).

Free WordPress Themes?

Finding a high-quality WordPress theme with a modern Web design, HTML5, customizable, without major bugs and well working is not so easy like many may initially assume. The are thousands free WordPress themes at WordPess.org themes directory but to be honest 99% of them are bull shit.

Collecting High-Quality Free WordPress Themes

I have a nice habit: collecting good free WordPress themes. In my daily work if occasionally I some Web site with a good WordPress theme catches my eyes, I check its and its theme. If the site is WordPress based and it theme is free, I collect the theme name and its download URL. I do this because due to marketing, spam and SEO, it is hard to find really free and really high-quality WordPress themes on the Web. Most sites advertise a theme as free and high-quality, but the reality is different.

How Do I Check If Certain WordPress Theme is Free?

Just click [Ctrl+U] (view page source) and then [Ctrl+F] (find text) an search for “wp-content/themes” or just “themes/”, then see the name of the theme, e.g. “snowblind”. Once you know the theme name, find the theme site in Google (e.g. search for “snowblind theme wordpress”). At the theme Web site check whether it is free and optionally try to download, install and test it.

High-Quality Free WordPress Themes – My Favorites

After few months I came to the following 10 free high-quality WordPress themes which are my favorites:

  • Snowblind – http://wordpress.org/extend/themes/snowblind
  • Ashford – http://ashford.turtleinteractive.com
  • Natura – http://newwpthemes.com/natura-free-wordpress-theme
  • ZBench – http://wordpress.org/extend/themes/zbench
  • Bueno – http://www.woothemes.com/2009/11/bueno
  • IFeature – http://wordpress.org/extend/themes/ifeature
  • Skeleton – http://demos.simplethemes.com/skeleton
  • iTheme2 – http://themify.me/themes/itheme2
  • Busby – http://wplift.com/themes/busby
  • Boldy – http://wordpress.site5.net/boldy (does not work with Bulgarian content)

New nice free WordPress themes I found after the original publication of this blog post

  • Famous – http://wordpress.org/extend/themes/famous
  • LANDA – http://newwpthemes.com/landa-free-wordpress-theme/

Happy wordpressing … and if you need some day a really good free WordPress theme, check the list above. Also feels free to share your favorites in the comments below.

Ventsislav Dimitrov, Атанас Чавдаров, Ognian Mladenov, Vladislav Jordanòv, Georgi Yankov, Vladi Ivanov, Dmitry Alexandrov, Mike Ramm, Yordan Zashev, Mia FromMars, Благовест Клисарски liked this post

Tags: free, free high-quality WordPress themes, free themes, free WordPress themes, high-quality free WordPress themes, themes, WordPress, WordPress themes

Previews (70,894), Views (9,366), Comments (7)

Author: Svetlin Nakov

April 30, 2012

  • Svejo.net
  • Tweet

Open Questions Plugin for Question2Answer Q&A Platform

I use the Questions2Answer Q&A platform (Q2A) for Telerik Software Academy forums. It is great discussion board implemented in the “stackoverflow” style: questions with answers and comments, tags and categories, voting and gamification with a score system and a leaderboard.

One feature missing in Q2A is displaying the open unanswered questions. There is a similar feature called “Unanswered Questions” but it is useless because it shows the closed questions without answer. This is strange. Once a question is closed, this means its answer has been found by its author or the question is found to be duplicate or spam or irrelevant to the forum and should never be answered. Most Q&A users agree that all closed questions should be considered answered and not shown as “waiting an answer”.

Fixing the “Unanswered” Page in Q2A

The easiest way to fix the “Unanswered” questions page to exclude the closed questions is to change the line

$bysql='acount=0';

to

$bysql='acount=0 AND closedbyid IS NULL';

in the function “qa_db_unanswered_qs_selectspec” located in the file “qa-include/qa-db-selects.php”.

This ugly approach works but if you upgrade the Q2A software with a newer version, the fix will be lost. A better approach is to use a plug-in. It is not hard to write a plugin for Q2A platform because it is well written, structured and even documented and uses standard PHP and MySQL programming techniques and best practices.

Open Questions Plugin for Question2Answer

I created an open-source project in GitHub to host the “Open Questions” plugin for Q2A: https://github.com/nakov/q2a-plugin-open-questions. The plugin consists of 3 PHP files and it is relatively easy to understand how it works. The installation is trivial.

If you want to install it, just download the archive q2a-plugin-open-questions.zip and extract it into the “qa-plugin” directory of your Q2A installation and enable it through the Admin panel:

Q2A plugin "Open Questions" by Svetlin Nakov - Installation

Q2A plugin "Open Questions" by Svetlin Nakov - Screenshot

Yoan Krumov, Tihomir Iliev liked this post

Tags: closed, MySQL, Nakov, Open Questions, open unanswered questions, open-source, PHP, plugin, Q2A, Q2A plugin, Question2Answer, Question2Answer plugin, svetlin nakov, unanswered, waiting for answer

Previews (68,279), Views (1,253), Comments (1)

Author: Svetlin Nakov

December 26, 2011

  • Svejo.net
  • Tweet

Online AES Encryption Tool

Few day ago I needed a JavaScript AES implementation (the Rijndael advanced encryption algorithm) which I can test instantly in my Web browser (two fields “text” and “password” and “encrypt” button). I searched for “online AES tool” but found nothing that is ready-to-use so I needed to write one. For those who need instant online Browser-based JavaScript AES encryptor / decryptor that runs without any plugins client-side, enjoy! Thanks to Mark Percival for his AES JavaScript library.

How the JavaScript AES Encryptor / Decryptor Works?

This online form encrypts with AES (Rijndael) instantly given text with the AES-128 algorithm and produces a BASE64-encoded output: cipher = BASE64_Encode(AES_Encrypt(text, password)). The algorithm first extracts a 128-bit secret key and AES IV (initial vector) from the password and then after padding the input encrypts it (by 128-bit blocks). Finally the encrypted binary result is encoded in BASE64. A random salt is injected along with the password to strengthen the encryption code. The key-extraction algorithm and the format of the output AES-encrypted message is compatible with OpenSSL.

The decryption algorithm first decodes the BASE64 string, extracts from it the random salt used during the encryption, extracts the AES key and IV from the password and the salt and decrypts back the encrypted text.

The encryption / decryption implementation of the AES (Advanced Encryption Standard, a.k.a. Rijndael) algorithm in JavaScript is written by Mark Percival (see his open-source project gibberish-aes at GitHub).

AES Online Encryption Tool – Source Code

Below is the source code of the online AES encryption tool:

<!DOCTYPE html>
<html>

<head>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script type="text/javascript" src="https://raw.github.com/mdp/gibberish-aes/master/src/gibberish-aes.js"></script>
	<title>Free Online AES Tool - Encrypt / Decrypt Text with AES Online</title>
</head>

<body>
	<h1>Online AES Encryptor / Decryptor - Free AES Tool</h1>
	<h2>(JavaScript client-side AES cipher implementation)</h2>

	<table>
		<tr>
			<td>Text to encrypt:</td>
			<td><textarea id="text" />Enter the text to be encrypted here...</textarea></td>
		</tr>
		<tr>
			<td>Password:</td>
			<td><input id="password" value="some password" /></td>
		</tr>
		<tr>
			<td>Encrypted text:</td>
			<td><textarea id="encryptedText" readonly="readonly"></textarea></td>
		</tr>
		<tr>
			<td>Decrypted text:</td>
			<td><textarea id="decryptedText" readonly="readonly"></textarea></td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<button id="buttonStart">AES Encrypt / Decrypt</button>
			</td>
		</tr>
	</table>

	<script>
		$('#buttonStart').click(function() {
			var text = $('#text').val();
			var pass = $('#password').val();
			GibberishAES.size(128);
			var encrypted = GibberishAES.enc(text, pass);
			$('#encryptedText').val(encrypted);
			var decrypted = GibberishAES.dec(encrypted, pass);
			$('#decryptedText').val(decrypted);
		});
	</script>
</body>
</html>

Tags: 128-bit AES encryption tool, AES, AES crypt online, AES decrypt, AES encrypt, AES encrypt text by password, AES encryption online, AES encryption tool online, AES example, AES in JavaScript, AES JavaScript, AES online decryption, AES online encryption, AES online tool, AES OpenSSL, AES tool, AES tool online, BASE64, browser-based AES tool, EAS cipher online, encrypt and decrypt with AES online, encryption algorithm online, free AES tool online, free online AES tool, instant AES encryption, JavaScript AES calculator, online encryption tool, OpenSSL, Rijndael AES, Rijndael AES tool, Rijndael online tool, Web browser AES tool

Previews (43,315), Views (29,977), Comments (12)

Author: Svetlin Nakov

November 23, 2011

  • Svejo.net
  • Tweet

Simplified Console Input Class for C#, Similar to “cin >> a >> b” in C++ and java.util.Scanner

Recently I was again asked how do we perform “cin >> a >> b” in C# or how we can enter a sequence of numbers from the console in C#. In C++ we have very powerful class called “cin” (more correctly std::cin located in the standard library “iosteam”) that overloads the >> operator and allows entering anything from the standard input (stdin): numbers, characters, strings and other data types.

I searched for “cin in C#” and found nothing similar to “std::cin” for C#, so I needed to write such a class.

The Nakov.IO.Cin Class – “cin” Functionality for C# / .NET

Initially I had an idea to implement my C# “cin” class exactly like in C++. Unfortunately this was impossible because the C# language has certain limitations:

  • You cannot override the >> operator in C# for any type except int
  • You cannot override the >> operator in C# for output / by-ref types (e.g. out int, ref int)
  • You cannot add extension methods to the Console class because it is static (so additions like Console.Cin, Console.NextInt(), Console.In << x << b and Console.Cin.NextInt() cannot be added to it)

Finally I decided to implement my C# console simplifies reader it in a way similar to the Java syntax used in the java.util.Scanner class. See the code below:

namespace Nakov.IO
{
    using System;
    using System.Text;
    using System.Globalization;

    /// <summary>
    /// Console input helper for C# and .NET. Allows simplified reading of numbers and string
    /// tokens from the console in a way similar to "cin" in C++ and java.util.Scanner in Java.
    /// </summary>
    ///
    /// <copyright>
    /// (c) Svetlin Nakov, 2011 - http://www.nakov.com
    /// </copyright>
    ///
    /// <example>
    /// // In C++ we will use "cin >> x >> y;"
    /// // Using Nakov.IO.Cin we can do the same as follows:
    /// int x = Cin.NextInt();
    /// double y = Cin.NextDouble();
    /// </example>
    ///
    public static class Cin
    {
        /// <summary>
        /// Reads a string token from the console
        /// skipping any leading and trailing whitespace.
        /// </summary>
        public static string NextToken()
        {
            StringBuilder tokenChars = new StringBuilder();
            bool tokenFinished = false;
            bool skipWhiteSpaceMode = true;
            while (!tokenFinished)
            {
                int nextChar = Console.Read();
                if (nextChar == -1)
                {
                    // End of stream reached
                    tokenFinished = true;
                }
                else
                {
                    char ch = (char)nextChar;
                    if (char.IsWhiteSpace(ch))
                    {
                        // Whitespace reached (' ', '\r', '\n', '\t') -->
                        // skip it if it is a leading whitespace
                        // or stop reading anymore if it is trailing
                        if (!skipWhiteSpaceMode)
                        {
                            tokenFinished = true;
                            if (ch == '\r' && (Environment.NewLine == "\r\n"))
                            {
                                // Reached '\r' in Windows --> skip the next '\n'
                                Console.Read();
                            }
                        }
                    }
                    else
                    {
                        // Character reached --> append it to the output
                        skipWhiteSpaceMode = false;
                        tokenChars.Append(ch);
                    }
                }
            }

            string token = tokenChars.ToString();
            return token;
        }

        /// <summary>
        /// Reads an integer number from the console
        /// skipping any leading and trailing whitespace.
        /// </summary>
        public static int NextInt()
        {
            string token = Cin.NextToken();
            return int.Parse(token);
        }

        /// <summary>
        /// Reads a floating-point number from the console
        /// skipping any leading and trailing whitespace.
        /// </summary>
        /// <param name="acceptAnyDecimalSeparator">
        /// Specifies whether to accept any decimal separator
        /// ("." and ",") or the system's default separator only.
        /// </param>
        public static double NextDouble(bool acceptAnyDecimalSeparator = true)
        {
            string token = Cin.NextToken();
            if (acceptAnyDecimalSeparator)
            {
                token = token.Replace(',', '.');
                double result = double.Parse(token, CultureInfo.InvariantCulture);
                return result;
            }
            else
            {
                double result = double.Parse(token);
                return result;
            }
        }

        /// <summary>
        /// Reads a decimal number from the console
        /// skipping any leading and trailing whitespace.
        /// </summary>
        /// <param name="acceptAnyDecimalSeparator">
        /// Specifies whether to accept any decimal separator
        /// ("." and ",") or the system's default separator only.
        /// </param>
        public static decimal NextDecimal(bool acceptAnyDecimalSeparator = true)
        {
            string token = Cin.NextToken();
            if (acceptAnyDecimalSeparator)
            {
                token = token.Replace(',', '.');
                decimal result = decimal.Parse(token, CultureInfo.InvariantCulture);
                return result;
            }
            else
            {
                decimal result = decimal.Parse(token);
                return result;
            }
        }
    }
}

How Cin.NextDouble() Works?

My class Nakov.IO.Cin allows simplified entering string tokens, integer numbers, floating-point numbers and decimal numbers in C# from the standard input (the console). When reading a sequence of numbers, we can separate them with a single space, multiple spaces, new line separators or any other sequence of whitespace characters: spaces, tabs, new lines (\n, \r\n), etc.

In addition Nakov.IO.Cin solves the culture-specific problem with the decimal point separator which may be “,” in some countries (like Bulgaria) and “.” in other countries (like USA and Canada). The Cin.NextDouble() and Cin.NextDecimal() methods accept a Boolean parameter which specifies whether the numbers should be parsed using the default decimal separator (specified in the regional settings in Windows) or by accepting both separators: “.” and “,”. By default both decimal separators are accepted when entering numbers by Nakov.IO.Cin.NextDouble() and Nakov.IO.Cin.NextDecimal().

Using the Nakov.IO.Cin Class – Example

In the below example I show how to use the class “Nakov.IO.Cin” to enter integer numbers, floating-point numbers, decimal numbers and string tokens:

using System;
using Nakov.IO; // see http://www.nakov.com/tags/cin

public class CinExample
{
    static void Main()
    {
        Console.Write("Enter your name: ");
        string name = Console.ReadLine();

        Console.Write("Enter two integers x and y separated by whitespace: ");
        // cin >> x >> y;
        int x = Cin.NextInt();
        double y = Cin.NextDouble();

        Console.Write("Enter your age: ");
        int age = int.Parse(Console.ReadLine());

        Console.WriteLine("Name: {0}, Age: {1}", name, age);
        Console.WriteLine("x={0}, y={1}", x, y);

        Console.Write("Enter a positive integer number N: ");
        int n = Cin.NextInt();

        Console.Write("Enter N decimal numbers separated by a space: ");
        decimal[] numbers = new decimal[n];
        for (int i = 0; i < n; i++)
        {
            numbers[i] = Cin.NextDecimal();
        }

        Console.Write("The numbers in ascending order: ");
        Array.Sort(numbers);
        for (int i = 0; i < n; i++)
        {
            Console.Write(numbers[i]);
            Console.Write(' ');
        }
        Console.WriteLine();

        Console.WriteLine("Enter two strings seperated by a space: ");
        string firstStr = Cin.NextToken();
        string secondStr = Cin.NextToken();
        Console.WriteLine("First str={0}", firstStr);
        Console.WriteLine("Second str={0}", secondStr);
    }
}

Translating from C++ “cin” to C# Using the C# “cin” Class

Once you have included the class Nakov.IO.Cin to your C# / VB.NET project, you could translate the following C++ program into C#:

Sample C++ code entering a number N and a sequence of N integer numbers, separated by a space (or any other sequence of whitespace characters):

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;

    int* numbers = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> numbers[i];
    }

    for (int i = 0; i < n; i++)
    {
        cout << numbers[i] << ' ';
    }
}

The same code written in C# using the C# “cin” class (Nakov.IO.Cin) is as follows:

using System;
using Nakov.IO; // see http://www.nakov.com/tags/cin

public class EnteringNumbers
{
    static void Main()
    {
        int n;
        n = Cin.NextInt();

        int[] numbers = new int[n];
        for (int i = 0; i < n; i++)
        {
            numbers[i] = Cin.NextInt();
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(numbers[i] + " ");
        }
    }
}

With both the programs (the C++ and the C# one) you are free to enter all the requested numbers on a single line (e.g. “3   1 –2   3”) or on separate lines (e.g. “\r\n 3 \r\n   1 \t –2 \r\n\r\n  3”)) and they will be parsed correctly, as expected.

Download the Nakov.IO.Cin Class

  • Download the full source code and examples: Nakov.IO.Cin.zip.
  • Download the C# class source code only: Cin.cs.
  • Browse the Nakov.IO.Cin project repository at GitHub.

Tags: C#, C# cin, C# cin class, C# console, C# console cin, C++ cin for C#, cin, cin >> a >> b in C#, cin >> a in C#, cin class C#, cin for .NET, cin for C#, Console.NextDouble(), Console.NextInt(), Console.NextInt() in C#, Console.NextToken(), CSharp, java.util.Scanner, java.util.Scanner in C#, Nakov.IO.Cin, std::cin, std::cin C#, stdin

Previews (12,032), Views (1,291), Comments (5)
Older Posts »

Top Posts

  • Семинар “Как да си намерим работа в ИТ индустрията?” – CV, cover letter, интервю

  • Университет като за софтуерни инженери: къде да учим програмиране след 12 клас? (класацията на Наков)

  • Rejected a Program Manager Position at Microsoft Dublin – My Successful Interview at Microsoft

  • My Interview at Google in Zurich

Translation

Recent Posts

  • Представяне на NASA Space Apps Challenge на 2 април 2013
  • Как да презентираме вдъхновяващо с майсторлък? Мурафетите на Наков
  • Пролетен прием в софтуерната академия: 500 нови студента от април
  • Безплатен курс “Бизнес умения за софтуерни инженери” – от 27 март
  • 580 продължават безплатното си обучение в софтуерната академия след изпитите по CSS и C# част 2

Recent Comments

  • Paul Crocker on X.509 Certificate Validation in Java: Build and Verify Chain and Verify CLR with Bouncy Castle: Thanks - It works fine for me after tidying the code up a bit and...
  • look at this web-site on Безплатните курсове в Академията на Телерик за софтуерни инженери – какво да очакваме за 2011-2012?: But beyond the financial implications it is the most logical thing in the world, but...
  • check This link right Here now on 85 продължават в Софтуерната академия в курса Software Engineering Basics от 17 април: Isn't the very name," National News" mean that it s not just about themedication. Our...
  • Serena-Ilsuospazio.Blogspot.com on Нов безплатен курс по уеб дизайн с HTML 5, CSS и JavaScript – от март в академията на Телерик: The National Governors' Association said Medicaid coverage of farmacia on line was told yesterday he...
  • http://www.youtube.com/watch?v=Oo_J84HeWKY on Telerik School Academy: It's difficult to find well-informed people on this topic, but you seem like you know...

Archives

  • March 2013 (4)
  • February 2013 (5)
  • January 2013 (7)
  • December 2012 (1)
  • November 2012 (11)
  • October 2012 (8)
  • September 2012 (8)
  • August 2012 (2)
  • July 2012 (10)
  • June 2012 (1)
  • May 2012 (9)
  • April 2012 (9)
  • March 2012 (9)
  • February 2012 (10)
  • January 2012 (8)
  • December 2011 (5)
  • November 2011 (12)
  • October 2011 (18)
  • September 2011 (16)
  • August 2011 (7)
  • July 2011 (7)
  • June 2011 (2)
  • May 2011 (3)
  • April 2011 (10)
  • March 2011 (8)
  • February 2011 (5)
  • January 2011 (7)
  • December 2010 (3)
  • November 2010 (17)
  • October 2010 (8)
  • September 2010 (4)
  • August 2010 (2)
  • July 2010 (4)
  • June 2010 (3)
  • May 2010 (4)
  • April 2010 (2)
  • March 2010 (1)
  • February 2010 (2)
  • January 2010 (4)
  • December 2009 (3)
  • November 2009 (6)
  • October 2009 (3)
  • September 2009 (6)
  • July 2009 (4)
  • June 2009 (1)
  • May 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • September 2008 (1)
  • August 2008 (5)
  • July 2008 (2)
  • June 2008 (4)
  • May 2008 (2)
  • April 2008 (1)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (1)
  • December 2007 (4)
  • November 2007 (7)
  • October 2007 (3)
  • September 2007 (9)
  • August 2007 (5)

RSS Academy Forums

  • Къде може да видим примерни тестове и какво се случва ако не успееш да изкараш достатъчно добър резултат ?
  • Answered: До Дончо и другите трейнъри: Моля, четете коментарите към оценките на изпита по JS2
  • Answered: [JS] Проверка на изпити
  • Data Type Short
  • Answered: Колко домашни оценихте?

navigation:

Home About Books Courses Presentations Videos Research Publications Others Contacts
Svetlin Nakov @ Google+

My Projects

  • GWT Advanced Table
  • Internet Programming with Java Book
  • Intro C# Programming Book
  • Intro Java Programming Book
  • Java For Digitally Signing Documents In Web Book
  • Programming for .NET Framework Book
  • Software University

Useful Links

  • Bulgarian Association of Software Developers (BASD)
  • Free Java and Java EE Course
  • NLP Club Bulgaria
  • Stefan Kanev's Blog
  • Telerik Academy
  • Telerik Kids Academy
  • Telerik School Academy

Categories

  • .net
  • blog
  • bulgarian
  • career
  • contests
  • courses
  • english
  • HTML5
  • java
  • seminars
  • НЛП
  • предприемачество

Recent Posts

  • Представяне на NASA Space Apps Challenge на 2 април 2013
  • Как да презентираме вдъхновяващо с майсторлък? Мурафетите на Наков
  • Пролетен прием в софтуерната академия: 500 нови студента от април
  • Безплатен курс “Бизнес умения за софтуерни инженери” – от 27 март
  • 580 продължават безплатното си обучение в софтуерната академия след изпитите по CSS и C# част 2

Copyright © 1999 - 2013 Svetlin Nakov