Showing posts with label VS2013. Show all posts
Showing posts with label VS2013. Show all posts

Sunday, January 22, 2017

View Line Number in VS2013




*g' jelas... =))

Friday, June 17, 2016

Main C# Collections - Part 1

Di C# ada beberapa collection, antara lain :
  • List
  • ArrayList
  • HashTable
  • Stack
  • Queque
  • Dictionary
  • NameValueCollection
Soo...Pertama-tama kita bahas yaaang List... Jadi silahkan buat project baru di visual studio... :D... Daaan..berikut operasi2 dasarnya...
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CsharpCollection
{
    class Program
    {
        static void Main(string[] args)
        {
            /*** Nampung list untuk integer ***/
            List<int> intList = new List<int>();
            
            /**** Nambain Element *****/
            intList.Add(3);
            intList.Add(5);
            intList.Add(7);
            intList.Add(9);
            intList.Add(2);
            intList.Add(6);


            /*** Ukuran/jumlah element dalam list ***/
            Console.WriteLine("Jumlah Element : "+intList.Count);
            Console.WriteLine("Isi intList : ");
            foreach (int a in intList) Console.WriteLine(a);


            /*** insert item baru ***/
            intList.Insert(2,99);
            intList.Insert(5, 99);
            Console.WriteLine("\nIsi intList setelah insert element : ");
            foreach (int a in intList) Console.WriteLine(a);
            
            
            /*** search element dalam list ****/
            Console.WriteLine(" search 7 : "+intList.Contains(7));
            Console.WriteLine(" index 7 : "+intList.IndexOf(7));
            Console.WriteLine(" search 77 : " + intList.Contains(77));
            Console.WriteLine(" index 77 : " + intList.IndexOf(77));


            /*** sort item dalam list ***/
            intList.Sort();
            Console.WriteLine("\nIsi intList setelah di-sort : ");
            foreach (int a in intList) Console.WriteLine(a);

            /*** remove item ***/
            Console.WriteLine(" remove 99 : " + intList.Remove(99));
            Console.WriteLine(" remove 999 : " + intList.Remove(999));


            /*** clear total isi list ***/
            intList.Clear();

            
            Console.ReadLine();
        }
    }
}
Hasil :

Terus untuk yg rada advance dikit.... Seperti ini :
Pertama-tama bikin class baru :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  public class akatsuki
    {
        public string name { get; set; }
        public int rating { get; set; }
        public string jutsu { get; set; }


        public override string ToString()
        {
            return "Name : "+ name+ ", Rating : "+ rating+ ", Jutsu "+jutsu;
        }
    }
Berikut operasi-operasinya....
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CsharpCollection
{
    class Program
    {
        static void Main(string[] args)
        {
            /*** Deklarasi ***/
            List<akatsuki> myList = new List<akatsuki>();
            
            /*** Nambain element baru ***/
            myList.Add(new akatsuki() { name = "Itachi", rating=91, jutsu="Izanami"});
            myList.Add(new akatsuki() { name = "Hyosoka", rating = 93, jutsu = "Bungeejigum" });
            myList.Add(new akatsuki() { name = "Nagato", rating = 91, jutsu = "Sira Tensei" });
            myList.Add(new akatsuki() { name = "Poipo", rating = 91, jutsu = "xxxxx" });

            /* Nampilin element */
            foreach (akatsuki a in myList) Console.WriteLine("Nama : "+a.name + " Rating : "+a.rating+ " Jutsu : "+a.jutsu);


            /* Search item */
            Console.WriteLine("\nElement dengan nama Itachi : "+myList.Find(x=>x.name.Contains("Itachi")));
            Console.WriteLine("Element dengan rating 91 :" + myList.Find(x => x.rating == 91));
            Console.WriteLine("Element dengan rating 90:" + myList.Find(x => x.rating == 90));

            /*Exist method*/
            Console.WriteLine("\nApa ada yg ratingnya 93 ? : "+myList.Exists(x=>x.rating == 93));
            Console.WriteLine("Apa ada yg ratingnya 95 ? : " + myList.Exists(x => x.rating == 95));


            
            Console.ReadLine();
        }
    }



    public class akatsuki
    {
        public string name { get; set; }
        public int rating { get; set; }
        public string jutsu { get; set; }


        public override string ToString()
        {
            return "Name : "+ name+ ", Rating : "+ rating+ ", Jutsu "+jutsu;
        }
    }


}
Hasil :



Thursday, June 16, 2016

Deploying Website Using IIS in Windows 7

Naaah... disini kita udah punya website yang sudah siap dideploy, proses pembuatan websitenya bisa dilihat disini.. Terus skrg kita bakalan ngedeploy websitenya pake IIS. So silahkan buka IIS-nya terus Add new website :
Terus masukin properti yang dibutuhkan...
Klu udah selese... tar kita dapat site baru dipanel kiri seperti terlihat sebagai berikut :
Naaah....abis itu kita ke visual studio klik menu "Build" terus pilih "Publish WebSederhana"... WebSederhana itu nama projectnya....
Daaan.... Silahkan ikuti langkah2 dibawah sesuai gambar dibawah...





Naaah...setelah selese.... balik ke IIS, klik kanan simple website terus pilih yg start kyk gini :
Atau klu mau lngsung dari panel sebelah kanan juga ada... :D
Terus browse websitenya... boleh dari panel kyk yg ditunjukin panah ijo di atas, atau dari klik kanan terus pilih browse :
Hasilnya....
Oooops... ada yang lupaa... :D
Mmmm.... buka host file di C:\Windows\System32\drivers\etc
Terus tambain :
Terus folder simpleWeb-nya share :




Terus IIS untuk simple web direstart atau disetop terus di start lagi..
Klu di Runnn...
Ooopsss....masih error... :v
Mmmmm..... klihatannya kita harus ganti targetFrameworknya... hohoho... Pilih applicationPool..
Terus klik kanan yg simpleWeb...Terus pilih Advance setting...
Terus ganti target frameworknya jadi 4.0...
Abis itu restart lagi IIS simple site...Daaan... Hasilnya....Taaadaaaaaa.... :D

Cukup sekiaaan... :)

Membuat Website Sederhana Menggunakan ASP.NET-Web Form - Part 2

Okiee...,mmmm.... Berikutnya tambain kode ini di css...
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#nav li ul li {
    background-image:url(../Images/bar_background.png);
    background-size: cover;
    background-repeat: no-repeat;
    border: 3px solid #0be9f7;
    padding-left:10px;
    }

#nav a:link, #nav a:active, #nav a:visited{
    display: block;
    color: #000000;
    text-decoration: none;
}

#nav a:hover{
    color:lightblue;
}
Berikutnya... kita akan nambain pop window...So masukin lagi kode css ini :
1
2
3
#nav li:hover ul {
    display:block;
 }
Btw...#nav li: hover ul itu mengacu ke submenu soalnya id-nya adalah #nav terus turun satu langkah ke li. Nah li:hover, berarti li yg level 1 klu dihover, terus ada ul, berarti ul-nya punya display:block...Simplenya seperti itu maksdunya... Jadi klu ada #nav li ul li, berarti li yg pling terakhir yang disetting propertinya... :D
Hasil dari css display:block kyk gini :
Teruuuuus... kita tambain shadow dibagian navigation... Tambain kode ini di element navigation :
1
text-shadow: 0.1em 0.1em #0be9f7;
0.1em itu ngegeser ke kiri, terus 0.1em yang berikutnya ngegeser ke bawah..Terus yang pling belakang udah pasti tau semua ehehe.. :D *warna... Hasilnya kek gini :
Naaah...tuh shadownya... wkwkwk... *ngasal... :D
Terusssssss.... yang bagian footer juga diubaaah aaaaah... tambain yg ini :

Hasilnya :
Mmmm.....terus kita tambain content. Untuk contentnya ditambain dibagian <div id="content_area"> xxxxx </div> dan xxxxx-nya terserah ajjah... Klu Hisoka nambain kyk gini :
Siiipsss...segitu dulu ajjah.... :)

Kode lengkap untuk part ini, bisa dilihat disini..

Wednesday, June 15, 2016

splitOdd10 - Recursive - Java & C#

Given an array of ints, is it possible to divide the ints into two groups, so that the sum of one group is a multiple of 10, and the sum of the other group is odd. Every int must be in one group or the other. Write a recursive helper method that takes whatever arguments you like, and make the initial call to your recursive helper from splitOdd10(). (No loops needed.)

splitOdd10([5, 5, 5]) → true
splitOdd10([5, 5, 6]) → false
splitOdd10([5, 5, 6, 1]) → true

Java :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
public boolean splitOdd10(int[] nums) {
   return helper(0, nums, 0);
}

public boolean helper(int index, int[] nums, int result)
  { 
    if(index >= nums.length)
      {
        if ((result % 10) % 2 == 1) return true;
        else return false;
      }

    return helper(index + 1, nums, result + nums[index]);
  }

Test Result:

C#:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
public static Boolean splitOdd10(int[] nums)
        {
            return helper(0, nums, 0);
        }

public static Boolean helper(int index, int[] nums, int result)
        { 
            if(index >= nums.Length)
            {
                if ((result % 10) % 2 == 1) return true;
                else return false;
            }

            return helper(index + 1, nums, result + nums[index]);
        }

Test :

stringClean - Recursive - Java & C#

Given a string, return recursively a "cleaned" string where adjacent chars that are the same have been reduced to a single char. So "yyzzza" yields "yza".

stringClean("yyzzza") → "yza"
stringClean("abbbcdd") → "abcd"
stringClean("Hello") → "Helo"

Java :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
public String stringClean(String str) {
  //Stop Condition
  if(str.length()<2) return str;
  
  //Main recursive process
  int index = 0;
  for(index=0; index+1<str.length(); index++)
  {
    if(str.charAt(index) != str.charAt(index+1)) break;
  }
  return str.charAt(index)+stringClean(str.substring(index+1));
}

Test Result:

C#:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 public static string stringClean(string str)
        { 
            //kondisi setop
            if (str.Length < 2) return str;

            //main rekursif
            int index = 0;
            for (index=0; index+1 < str.Length; index++)
            {
                if (str[index] != str[index + 1]) break;
            }

            return str[index] + stringClean(str.Substring(index+1));

        }

Test Result :

allStar - Recursive - Java & C#

Given a string, compute recursively a new string where all the adjacent chars are now separated by a "*".

allStar("hello") → "h*e*l*l*o"
allStar("abc") → "a*b*c"
allStar("ab") → "a*b"
Java :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
public static String allStar(String str)
 {
  //Stop Condition
  if(str.length()<1) return "";
  if(str.length() == 1) return str+"*";
  
  
  //Main recursive process
  return str.charAt(0)+"*"+allStar(str.substring(1));
 }

Hasil :

C# :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
   public static string allStar(String str)
        { 
            //Kondisi stop
            if (str.Length < 1) return "";
            if (str.Length == 1) return str;


            //Proses rekursif
            return str[0] + "*" + allStar(str.Substring(1));
        }

Hasil :

array11 - Recursive - Java & C#

Given an array of ints, compute recursively the number of times that the value 11 appears in the array. We'll use the convention of considering only the part of the array that begins at the given index. In this way, a recursive call can pass index+1 to move down the array. The initial call will pass in index as 0.

array11([1, 2, 11], 0) → 1
array11([11, 11], 0) → 2
array11([1, 2, 3, 4], 0) → 0

Java :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public static int array11(int[] nums, int index)
 {
  //Stop Condition
  if(nums.length == 0 ) return 0;
  if(nums.length == 1)
  {
   if(nums[0] == 11) return 1;
   else return 0;
  }
  
  //Main recursive process
  int[] temp = Arrays.copyOfRange(nums, index+1, nums.length);
  if(nums[index] == 11) return 1+array11(temp,index);
  else return array11(temp,index);
 }
 

Test Result :

C# :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 public static int array11(int[] nums, int index)
        { 
            //Kondisi stop
            if (nums.Length == 0) return 0;
            if (nums.Length == 1)
            {
                if (nums[0] == 11) return 1;
                else return 0;
            }

            //Proses rekursif
            int[] temp = new int[nums.Length - index - 1];
            System.Array.Copy(nums, index+1, temp, 0, temp.Length);
            if (nums[index] == 11) return 1 + array11(temp, index);
            else return array11(temp, index);
        }

Test Result:


array6 - Recursive - Java & C#

Given an array of ints, compute recursively if the array contains a 6. We'll use the convention of considering only the part of the array that begins at the given index. In this way, a recursive call can pass index+1 to move down the array. The initial call will pass in index as 0.

array6([1, 6, 4], 0) → true
array6([1, 4], 0) → false
array6([6], 0) → true
Java :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public static boolean array6(int[] nums, int index)
 {
  //Stop condition
  if(nums.length == 0) return false;
  if(nums.length == 1)
  {
   if(nums[0]== 6) return true;
   else return false;
  }
  
  //Main process
  if(nums[index] == 6) return true;
  int[] temp = Arrays.copyOfRange(nums, index+1, nums.length);
        
  return array6(temp,index);
 }

Test Result:


C# :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public static Boolean array6(int[] nums, int index)
        { 
            //stop condition
            if (nums.Length == 0) return false;
            if (nums.Length == 1)
            {
                if (nums[0] == 6) return true;
                else return false;
            }
            if(nums[index] == 6) return true;

            //Main recursive process
            int[] temp = new int[nums.Length-index-1];
            System.Array.Copy(nums,index+1,temp,0,temp.Length);
            return array6(temp, index);
        }

Test Result: