Always getting NZEC Error

This is my code c# code,

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Playlist
{
class Program
{
static int n,m,cnt=0,key=-1;
static string pattern;
static List songs = new List();
static List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>();

    static int Main(string[] args)
    {
        string ip = Console.ReadLine();
        int t = Convert.ToInt32(ip);

        for (int i = 0; i < t; i++)
        {
            string ip1 = Console.ReadLine();
            string[] ipa1 = ip1.Split(' ');

            n = Convert.ToInt32(ipa1[0]);
            pattern = ipa1[1];
            m = Convert.ToInt32(ipa1[2]);

            for (int j = 0; j < n; j++)
            {                    
                songs.Add(Console.ReadLine());

                string re = pattern;
                re = re.Replace("_", ".");
                re = re.Replace("%", ".*?");
                MatchCollection mc= Regex.Matches( songs[songs.Count - 1] ,re);

                if (mc.Count >= m)
                {
                    list.Add(new KeyValuePair<string, int>(songs[songs.Count - 1], i));
                    cnt++;
                }
            }
        }
      
        foreach (KeyValuePair<string, int> kvp in list)
        {

            if (key != kvp.Value)
            {
                Console.WriteLine("Case: {0}", kvp.Value + 1);
                Console.WriteLine(kvp.Key);
                key = kvp.Value;
            }
            else
                Console.WriteLine(kvp.Key);
        }

        Console.Read();
        return 0;
    }
}

}

Can you please tell me why I am getting NZEC error?

@amrutalele NZEC stands for Non Zero Exit Code. For C users, this will be generated if your main method does not have a return 0; statement. Other languages like Java/C++ could generate this error if they throw an exception.

2 Likes

@amrutalele : You should not declare namespace

Check out sample solutions for the problem :

in all languages at :

Declaring namespace does not allow online judge to find your class containing “main” method .

Sample solution in c# for problem TEST .

using System;

public class Test

{

public static void Main()

{

int n;

while ((n = int.Parse(Console.ReadLine()))!=42)

Console.WriteLine(n);

}

}

Thanks for your help…