Types of Number literals in C#

Hi Folks,

In this post I touch briefly on types of number literals in C# programming language.

An illustration is

var f = 0f; // float
var d = 0d; // double
var m = 0m; // decimal (money)
var u = 0u; // unsigned int
var l = 0l; // long
var ul = 0ul; // unsigned long

For example, this menas if you see a number with “m” suffix, it is a decimal literal.

That’s all for now. Till next time, happy software development.

How to assign data to properties when instantiating an object in c#

Hi Folks,

In this post, we talk about how to assign data to properties when instantiating an object in c#.

Suppose you have a class like

 

public class Album 
{
    public string Name {get; set;}
    public string Artist {get; set;}
    public int Year {get; set;}

    public Album()
    { }

    public Album(string name, string artist, int year)
    {
        this.Name = name;
        this.Artist = artist;
        this.Year = year;
    }
}

You can create an instance of Album class either via the constructor e.g.

var albumData = new Album("Albumius")
{
Artist = "Artistus",
Year = 2013
};

After compilation, this is similar to the following:

var albumData = new Album("Albumius");
albumData.Artist = "Artistus";
albumData.Year = 2013;

That’s all for now. Till next time, happy software development.

References

C# : assign data to properties via constructor vs. instantiating. stackoverflow. https://stackoverflow.com/questions/19138195/c-sharp-assign-data-to-properties-via-constructor-vs-instantiating

How to convert .mov file to .mp4 using ffmpeg

Hi Folks,

In this post I go over how to convert a .mov file to a .mp4 file using the terminal. Why should you know this skill? Well, you may have recorded a video using an iPhone. Usually these videos are formatted as .mov files. Let’s imagine you need to convert this to mp4 for whatever reason, how do you go about it?

If you have ffmpeg installed, you can use it for the conversion via the terminal. The command to run looks like:

ffmpeg -i {in-video}.mov -vcodec h264 -acodec aac {out-video}.mp4

That’s all for now. Till next time, happy video conversion!

Reference

convert .mov video to .mp4 with ffmpeg. Super User. https://superuser.com/questions/1155186/convert-mov-video-to-mp4-with-ffmpeg