Oya Koleksi Script yang akan A-F share buat kalian malam ini antara lain sebagai berukut :
- Menerima/mengirim nilai input/input dari dan ke user (10)
- Fungsi IF atau SWITCH Statement berdasarkan nilai input yang dimasukan oleh user (10)
- Fungsi FOR iteration (10)
- Tanggal sekarang dengan format 15 September 2013 08:00:00 (10)
- Penggunaan .NetClass (10)
- Membuat Class dan Namesapce pada file yang baru (10)
- Penggunaan Collection (10)
Langsung masuk ke Koleksi Script yang pertama :
- Menerima/mengirim nilai input/input dari dan ke user (10)
private void bt1_Click(object sender, RoutedEventArgs e)
{
string newvalue;
newvalue = input1.Text;
tmp1.Text = "Input : " + newvalue;
}
- Fungsi IF atau SWITCH Statement berdasarkan nilai input yang dimasukan oleh user (10)
private void bt2_Click(object sender, RoutedEventArgs e)
{
string newvalue2;
newvalue2 = input2.Text;
if (newvalue2 == "aja")
{
tmpl2.Text = "Anda Success aja !! ";
}
else if (newvalue2 == "sekali")
{
tmpl2.Text = "Anda sangat Success sekali !! ";
}
else if (newvalue2 == "beruntung")
{
tmpl2.Text = "Anda sangat Beruntung";
}
else
{
tmpl2.Text = "Kami tidak mengerti ";
}
}
- Fungsi FOR iteration (10)
private void bt3_Click(object sender, RoutedEventArgs e)
{
string message = "";
for (int i = 0; i < 10; i++)
{
message = message + i.ToString() + System.Environment.NewLine;
}
tmpl3.Text = message;
}
- Tanggal sekarang dengan format 15 September 2013 08:00:00 (10)
using System.Globalization;
private void bt4_Click(object sender, RoutedEventArgs e)
{
DateTime mytime = DateTime.Now;
CultureInfo cultureinfo = new CultureInfo("id-ID");
tmpl4.Text = mytime.ToString("dd MMMM yyyy hh:mm:ss",cultureinfo) ;
}
- Penggunaan .NetClass (10)
using Microsoft.Phone.Controls;
private void bt1_Click(object sender, RoutedEventArgs e)
{
Button newButton = new Button();
newButton.Name = "NewButton ";
newButton.Height = 72;
newButton.Width = 160;
newButton.Content = "New Button";
newButton.Margin = new Thickness(100.0, 100.0, 100.0, 100.0);
newButton.HorizontalContentAlignment = HorizontalAlignment.Stretch;
newButton.VerticalAlignment = VerticalAlignment.Stretch;
ContentGrid.Children.Add(newButton);
TextBox myTextbox = new TextBox();
myTextbox.Name = "New TextBox";
myTextbox.Height = 72;
myTextbox.Width = 380;
myTextbox.Margin = new Thickness(14, 170, 0, 0);
myTextbox.TextWrapping = TextWrapping.Wrap;
myTextbox.Text = "News TextBox";
myTextbox.VerticalAlignment = VerticalAlignment.Bottom;
ContentGrid.Children.Add(myTextbox);
}
- Membuat Class dan Namesapce pada file yang baru (10)
namespace Colecction { public class Handphone { public string Name { get; set; } public string Model { get; set; } } }
- Penggunaan Collection (10)
private void button1_Click(object sender, RoutedEventArgs e)
{
Handphone Handphone1 = new Handphone();
Handphone1.Name = "Nokia";
Handphone1.Model = "Lumia";
Handphone Handphone2 = new Handphone();
Handphone2.Name = "Blackberry";
Handphone2.Model = "BB Gemini";
Handphone Handphone3 = new Handphone();
Handphone3.Name = "Samsung";
Handphone3.Model = "Galaxy Core";
List<Handphone> mcList = new List<Handphone>();
mcList.Add(Handphone1);
mcList.Add(Handphone2);
mcList.Add(Handphone3);
string myHandphone = "";
foreach (Handphone mc in mcList)
{
myHandphone += mc.Name + " - " + mc.Model + Environment.NewLine;
}
CollectionTB.Text = myHandphone;
}
0 komentar:
Posting Komentar
Terimkasih Anda Sudah Bersedia Bekomentar Disini, Ingat Jangan Sampai Komentar anda Dapat Kartu Kuning !! Setiap KOmentar Yang Mendapat kan Kartu Kuning Tidak Di Tampilkan Di BLOG A-F Link anda akan Di Hapus !! salam Sukses ya Bro ... . . . :P