using System.Text; /// @author Vesa Lappalainen /// @version 07.10.2012 /// /// Esimerkkejä aliohjelminen kutsumisesta /// public class AliohjelmienKutsuminen { /// /// Aliohjelmien kutsuesimerkkejä /// /// ei käytössä public static void Main(string[] args) { // http://msdn.microsoft.com/en-us/library/xf2k8ftb%28v=vs.100%29.aspx // Namespace: System // Console.WriteLine Method (String) // public static void WriteLine(string value) System.Console.WriteLine("Moikka!"); char eka = 'A'; // http://msdn.microsoft.com/en-us/library/hhef7hhe%28v=vs.100%29.aspx // Namespace: System // Char.ToLower Method (Char) // public static char ToLower(char c) char pieni = System.Char.ToLower(eka); // http://msdn.microsoft.com/en-us/library/ewdd6aed%28v=vs.100%29.aspx // Namespace: System // String.ToUpper Method // public string ToUpper() string jono = "kalle"; string isona = jono.ToUpper(); // http://msdn.microsoft.com/en-us/library/system.math.sin%28v=vs.100%29.aspx // Namespace: System // Math.Sin Method // public static double Sin(double a) double kulma = System.Math.PI / 4; // 45 astetta double y = System.Math.Sin(kulma); // http://msdn.microsoft.com/en-us/library/5fxz4s6t%28v=vs.85%29.aspx // Namespace: System.Text // StringBuilder.StringBuilder(String) Constructor // public StringBuilder (string value) StringBuilder sb = new StringBuilder("Krokotiili"); // http://msdn.microsoft.com/en-us/library/4b1063zt%28v=vs.85%29.aspx // Namespace: System.Text // StringBuilder.ToString Method () // public override string ToString() string s = sb.ToString(); // http://msdn.microsoft.com/en-us/library/kwb0bwyd%28v=vs.100%29.aspx // Namespace: System // String.IndexOf Method (Char) // public int IndexOf(char value) int i = s.IndexOf('t'); /// http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.remove%28v=vs.100%29.aspx // Namespace: System.Text // StringBuilder.Remove Method // public StringBuilder Remove(int startIndex,int length) sb.Remove(0, i); // http://msdn.microsoft.com/en-us/library/b4sc8ca8%28v=vs.100%29.aspx // Namespace: System.Text // StringBuilder.Append Method (String) // public StringBuilder Append(string value) sb.Append("talo"); System.Console.WriteLine(sb); StringBuilder sb2 = new StringBuilder("Krokotiili"); System.Console.WriteLine(sb2.Remove(0,sb2.ToString().IndexOf('t')).Append("talo")); string s2 = "Krokotiili"; int tp = s2.IndexOf('t'); string s3 = s2.Substring(tp); string s4 = s3 + "talo"; System.Console.WriteLine(s4); string s5 = "Krokotiili"; System.Console.WriteLine(s5.Substring(s5.IndexOf('t'))+"talo"); System.Console.WriteLine("Krokotiili".Substring("Krokotiili".IndexOf('t')) + "talo"); System.Console.ReadLine(); } }