Category Archives: C#

New Features in C# 6.0 – Null-Conditional Operator


This is blog post series about new features coming in the next version of C# 6.0. The first post is about null conditional operator.

The NullReferenceException is night mare for any developer specially for developer with not much experience. Almost every created object must be check against null value before we call some of its member. For example assume we have the following code sample:

class Record
{
 public Person Person  {get;set;}
 public Activity Activity  {get;set;}
}
public static PrintReport(Record rec)
{
  string str="";
   if(rec!=null && rec.Person!=null && rec.Activity!=null)
   {
     str= string.Format("Record for {0} {1} took {2} sec.", rec.Person.FirstName??"",rec.Person.SurName??"", rec.Activity.Duration);
     Console.WriteLine(str);
   }

  return ;
}

We have to be sure that all of the object are nonnull, otherwize we get NullReferenceException.

The next version of C# is provide Null-Conditional operation which reduce the code significantly.

So, in the next version of C# we can write Print method like the following without fear of NullReferenceException.


public static PrintReport(Record rec)
{
  var str= string.Format("Record for {0} {1} took {2} sec.", rec?.Person?.FirstName??"",rec?.Person?.SurName??"", rec?.Activity?.Duration);
     Console.WriteLine(str);

  return;
}

As we can see that ‘?’ is very handy way to reduce our number of if statements in the code. The Null-Conditional operation is more interesting when is used in combination of ?? null operator. For example:


 string name=records?[0].Person?.Name??"n/a";

The code listing above checks if the array of records not empty or null, then checks if the Person object is not null. At the end null operator (??) in case of null value of the Name property member of the Person object put default string “n/a”.

For this operation regularly we need to check several expressions agains null value.
Happy programming.

 

My .NET Native session on MobilityDay 2014


md-badge_dev

MobilityDay conference is one of the best conference in the region about mobile technologies. It is one day conference, with several slots and great speakers from the whole Europe. Also most of the speakers hold MVP award. Every year I am visiting this conference as attender or as a speaker, because I spend great times there.

This year I am going to visit this conference as a speaker for the second time and I am very happy for that. I will be speaking about .NET Native precompilation techologiy which ordinary .NET application converts in to super fast application, as the same as VC++ would do. This is long waiting technology from Microsoft and the next version of the .NET will be armed with this great feature.

Come to Zagreb at Thursday at Hotel Antunovic and spend great time on the best conference about mobile technology.

Here is a quick infor about the session:

(C# Productivity) + (C++ Performance) = .NET Native

Level: 300
Hall: Dvorana 3
Time: 17:00 – 17:45
Description:
NET developers for years are faced with opinions that NET applications do not have the performance of native applications, and the reason is compiling IL code during execution of the application. On the other hand, there is a mountain of unnecessary library as an integral part of the NET Framework to create a “dependency” on the application themselves. Mirosoft in the next version of the NET Framework and Visual Studio wants to offer an entirely new way of distributing NET applications by offering the same compile the IL code, which is then over the NET native compilers translate into machine code in the same way as it would appear one VC ++ applications. With this move, Microsoft NET allows developers to develop high-performance applications, while retaining the maximum productivity of writing code that has C #. The lecture will present a Native NET compiler, and how to develop with him NET applications, high performance and which do not depend on the NET Framework.

Treća MSCommunityBH Konferencija, Hotel Sarajevo, 19/09/2014


badge-predavac

Treća po redu MSCommunityBH konferencija održava se ove godine u Hotelu Sarajevo,  19. septembra sa početkom u 9:00 sati. Iz godine u godinu konferencija sve više dobija na polularnosti ne samo u Bosni i Hercegovini nego i regionu. Organizirana od strane MSCommunit zajednice u Bosni i Hercegovini, lokalnog ureda Microsofta te sponzora koji od samog početka financiraju MSCommunity događaje zaista je svijetli primjer uspješne organizacije, uz pomoć lokalnih snaga i sponzora.

Pored izuzetno kvalitetnih predavača, kao i tema koja spadaju u sami vrh IC tehnologija sa akcentom na microsoftove tehnologije, konferencija daje priliku maldim ljudima da se upoznaju sa najnovijim tehnologijama iz područja razvoja softvera, Cloud Computinga (računanja u oblaku) ,  IT Pro tema, a  kroz networking razmjene iskustava i dobro se provedu.

Po treći put mi se ukazala mogućnost da na konferenciji održim predavanja iz oblasti razvojnih alata na .NET platformi. Predavanja počinje nakon otvaranje konferencije u 10:00 sati.

Tema: Visual Studio 14: Šta dolazi?
Nivo: 300
Opis:
Microsoft je još sa VS 2012 promijenio strategiju razvoja i objavljivanja Visual Studia koncepcijom kontinuiranog objavljivanja novih verzija svaka 4 mjeseca. Polazeći od Update 2 za Visual Studio 2013 preko Visual Studio 14 Microsoft je lansirao i najavio nekoliko vrlo važnih proširenja na .NET Frameworku odnosno na samom Visual Studiu. Ove promjene odnose se na sve četiri aktivne Microsoft platforme: Mobile, Desktop, Web i Cloud. Nova proširenja na mobilnoj platformi dolaze kako za nativni razvoj mobilnih rješenja preko integracije XAMARINa u Visual Studio, tako i miltiplatformski razvoj preko Multi-Device Hybrid proširenja za Visual Studio. Desktop platforma doživaljava veliki preobražaj pojavom nove .NET kompajlerske plaftorme „Roslyn“, novog 64 bitnog .NET kompajlera „RyuJIT“ i novog .NET Nativnog kompajlera „.NET Native“. Web platforma odnosno ASP.NET vNext dolazi u open source verziji sa podrškom za Mono odnosno podrškom za Linux i Mac. Novi razvojni alati donosi i unapređenja u razvoju cloud baziranih rješenja, a sa kombinacijom za Visual Studio Online i integracijom Visual Studia u Microsoft Azure daje nove koncepcije razvoja i održavanja sistema. Pored toga nadolazeća verzija Visual Studio 14 donosi mnoštvo alata za uređivanje koda, debuggiranja, memory profiling alate i drugo.

Vidimo se na konferenciji.

Compilers in .NET vNext my KulenDayz session


kulendayz

Next week I am going to KulenDayz event the most exciting and unique MSCommunity conference in the region. It will be my second time I am participating on the conference as a speaker. The KulenDayz IT conference is organized by Croatian Microsoft Community, mainly by .NET User Group from Osijek. The conference will be held in Osijek from 5th to 7th of September. The conference will gather the most important MSCommunity influencers from the Balkan and East Europe. Most of this guys are also Microsoft MVP from various expertize. The conference is organized thought 55 sessions in 8 tracks from the classic development to the Microsoft Azure, case studies etc. Between sessions there will be various interesting events, opportunity to make connection and meet various experts. Besides a good networking on the conference, I am very happy I going to see my friends from the region.

The uniqueness of the conference is the motto: Slow Down, which trying to tell every participant to be relaxed and to enjoythe event without any stress. Beside the motto and the way how it is organized, this is not all what guys from Osijek will offer this time. Actually there is a catch in one of 8 conference track. It is so special. It is KuelnDayz Kindz track which will offer IT sessions for kinds between 7-12.

kulendayz2012_1 kulendayz2012_2

As a KulenDayz speaker I will deliver session about very cool stuff coming with the next version of the .NET. The session will be a story about compilers in .NET vNext and how Microsoft brings innovation in to C# and VB compilers platform and the new 64 bit JIT compilers socalled RyuJIT compiler. Also the session will bring the news about .NET Native compiler. It is a new generation of .NET Native  compiler which .NET application compiles in to native application like C++ compiler does.

My session will start at 11:00 on advanced development track at Saturday 6th of September.

Meet you there.

Follow

Get every new post delivered to your Inbox.

Join 552 other followers