class Book { public string Title { get; set; } public int Pages { get; set; } public override string ToString() { return string.Format("Book {0} {1}", Title, Pages); } }
class CD { public string Title { get; set; } public int Volume { get; set; } public override string ToString() { return string.Format("CD {0} {1}", Title, Volume); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Patterns { class Program { static int totalValues(int[] values) { int total = 0; foreach (var value in values) { total += value; } return total; } static int totalEvenValues(int[] values) { int total = 0; foreach (var value in values) { if (value % 2 == 0) total += value; } return total; } static int totalOddValues(int[] values) { int total = 0; foreach (var value in values) { if (value % 2 != 0) total += value; } return total; } static int totalSelectValues(int[] values, Func<int, bool> selector) { int total = 0; foreach (var value in values) { // pass value(first param) into function and return second param value if (selector(value)) total += value; } return total; } // static void Main(string[] args) { int[] values = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Patterns { class Program { class Resource { //Call Resource class from here public static void Use(Action<Resource> block) { Resource resouce = new Resource(); try { block(resouce); } finally { resouce.Clearnup(); } }
//change public to protected // can't new class in normal way : class _class = new class() protected Resource() { Console.WriteLine("Creating..."); } public void op1() { Console.WriteLine("op1..."); } public void op2() { Console.WriteLine("op2..."); } private void Clearnup() { Console.WriteLine("cleanup exensive resource"); } } public static void Main(string[] args) { { Resource.Use( (resource) => { resource.op1(); resource.op2(); }); } Console.WriteLine("out of the block"); } } }
Ater upgrading to AS 0.5.4 I am getting this error 「Failed to set up SDK
Error:Module 『AndroinoTerm』: platform 『android-18』 not found」 while I already have android-18 installed. My sdk path is correctly setup and I am also able to run my project successfully. Does Anybody else having this issue ?
Solution:
1. Change sdk folder location
2. update sdk path in android studio
3. change back to original location
4. update sdk path setting in android studio again
5. problem solved
In your Windows 8 VM, go to Control Panel > System > Advanced system settings > Computer Name and click Change. Name this whatever you like, e.g. 「windows」. Restart your VM.
Open CMD or Powershell as administrator. Add a URL ACL entry for your new name on the port of your choice, e.g.
netsh http add urlacl url=http://windows:8080/ user=everyone
Open CMD or Powershell as administrator. Add an inbound firewall rule for this new port. In Windows 8, the syntax is:
netsh advfirewall firewall add rule name=「IISExpressWeb」 dir=in action=allow protocol=TCP localport=8080
In Windows 7, the syntax is:
netsh firewall add portopening TCP 8080 IISExpressWeb enable ALL
Edit your IISExpress applicationhost.config file, typically found at your Documents\IISExpress\config\applicationhost.config. Find your site under sites, and add a binding to the port using your machine name, e.g.
Startup IISExpress with Visual Studio, hit your URL from a browser on your Mac/VM Host, e.g. http://windows:8080