12. Xamarin Advantage
● Creating Android Project by C#
○ Can use LINQ and lambda
○ Using delegate, your coding smart.
● XamarinStudio(IDE) is cool!!
● Can Use VisualStudio.(by pay plan)
17. Problem 1
Can't use default and named arguments.
public void calc(){
sum(x: 3, y: 2, z: 1);//6
sum(x: 3, z: 1);//4
sum();//0
sum(z: 1);//1
}
public int sum(int x = 0,int y = 0,int z = 0){
return x + y + z;
}
18. Care of
Using HashMap?
public void calc(){
HashMap<String, int> map = new HashMap<String, int>
map.putInt("x", 10);
sum(map);//10
}
public int sum(HashMap<String, int> map){
if(map == null) return 0;
int x = map.put("x") == null ? 0 : map.put("x");
int y = map.put("y") == null ? 0 : map.put("y");
int z = map.put("z") == null ? 0 : map.put("z");
return x + y + z;
}
19. Problem 2
Can't use Lambda and Predicate(LINQ).
-List filtering-
public class Point{
public x { get: set:}
public y { get: set:}
public Point(int x, int y){
this.x = x;
this.y = y;
}
}
public void hoge(){
var list = new List<Point>();
list.Add(new Point(1,2))
list.Add(new Point(-1,2))
list.Add(new Point(1,-2))
list.Where(point p => p.x > 0);
}
20. Care of
Using inner Interface?
public class PointList extends ArrayList<Point>{
public PointList where(FilterInterface filter){
reutrn filter.filter(this);
}
public interface FilterInterface{
public PointList filter(PointList target);
}
}
21. implements
public void hoge(){
PointList list = new PointList();
list.Add(new Point(1,2));
list.Add(new Point(-1,2));
list.Add(new Point(1,-2));
list.where(new PointList.FilterInterface(){
@Override
public PointList filter(PointList target){
PointList flist = new PointList();
for(Point p : target)
if(p.x > 0)
flist.add(p);
return flist;
}
});
}