Tuesday, May 20, 2014

Basic JQuery Filters

Using Basic JQuery Filters
This is in the notes that i found from a video. To filter use below code,a dd it with your selection.

Filter Purpose
:first Select only the first instance
:last Select only the last instance
:even Select only even-numbered
:odd Select only the odd-numbered
:eq(n) Filters out elements that are not positioned at the given index
:gt(n) Includes elements that are past before the given index
:lt(n) Includes elements (H1,H2,H3,etc)
:animated Selects all elements that are currently being animated in some way.
:not(selector) Includes elements that do not match the given selector


For Example :
$("document").ready(function(){
   $("p:first").css("border", "3px solid red");
});

*p is for paragraph selected

Sunday, April 27, 2014

C# Creating new file and edit existing file.










This is the example exercises that I tried.

1. When creating a new text file using

Console.Write("\nPlease input filename : ");
string name = Console.ReadLine();
path += Path.DirectorySeparatorChar+ name + ".txt";
File.Create(path).Close();
  // Please bear in mind that you need to close the created process after create a file so that you can edit it later on.

2.When editing a file why would need to type the file name as you can list and choose the file number.

// Listing the existing file codes......
public string choose(string view)
        {
            Console.WriteLine("Please choose the existing file ");
            Console.WriteLine("--------------------------------");
            string[] choose= Directory.GetFiles(view);
            int i = 0;
            foreach (string s in choose)
            {   i++;
                Console.WriteLine("No {0} : " + s, i);               
            }
            Console.WriteLine("Please enter your selection file : ");
            i= int.Parse(Console.ReadLine());
            Console.WriteLine(choose[i - 1]);
            Console.ReadLine();
            return (choose[i - 1]);
        }

// Edit code...

public void editFile(string p)
        {
            string current = File.ReadAllText(p);
            Console.WriteLine("Opening file : "+ p);
            Console.WriteLine(current);
            string answer = "n";
            do
            {
                Console.WriteLine("Please write below your new text : ");
                current = Console.ReadLine();
                Console.WriteLine("\nAre you sure to save? (y/n)"); ///need improvise /evolution
                answer = Console.ReadLine();
            } while (answer != "y" );
            if (answer == "y")
            {
                File.WriteAllText(p, current);
                Console.WriteLine("Your text have been save.");
            }
            else Console.WriteLine("Your text have NOT been save.");
            Console.ReadLine();           
        }

* I still haven't found a really good codes to go with the (y/n/q) selection.

Learning C# codes.. Instructor


Whenever we starts a program the system will establish as following codes...

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

Hm.... i always wonder why do we need intstructor... such as

      class myClass
        {
            public myClass(string defaultMsg)
            {
                myMessage = defaultMsg;
            }

        }
Up until now i wonder the differences between these two method? Argh..... the explanation that i read is confusing....#%^&*^&(@

Sigh.... my life must carry on....  i just hope when i learn more i''ll understand it....