小编101*_*010的帖子

C#传递函数作为参数

我在C#中编写了一个函数来进行数值微分.它看起来像这样:

public double Diff(double x)
{
    double h = 0.0000001;

    return (Function(x + h) - Function(x)) / h;
}
Run Code Online (Sandbox Code Playgroud)

我希望能够传递任何功能,如:

public double Diff(double x, function f)
{
    double h = 0.0000001;

    return (f(x + h) - f(x)) / h;
}
Run Code Online (Sandbox Code Playgroud)

我认为这对代表来说是可能的(也许?)但是我不确定如何使用它们.

任何帮助将不胜感激.

c# arguments

123
推荐指数
3
解决办法
22万
查看次数

在Google地图片段中膨胀XML时出错

尝试使用片段显示Google地图.使用以下页面作为教程.

我得到异常"错误膨胀类片段".

1)导入jar google-play-services.jar

2)下载并配置了google play services SDK.

3)获得最新的v2 API密钥.

4)在清单中添加了com.google.android.providers.gsf.permission.READ_GSERVICES权限.

5)使用mindsdk = 8和target = 16.

供参考,Androidmanifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.com.mapsdemo"
android:versionCode="1"
android:versionName="1.0" >

<uses-feature android:glEsVersion="0x00020000" android:required="true"/>

<permission
android:name="com.example.com.mapsdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.com.mapsdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.com.mapsdemo.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDXPsxWF634gd907NzZKkRkNS0oH9IPWgk"/>


</application>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

package com.example.com.mapsdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu; …
Run Code Online (Sandbox Code Playgroud)

xml android google-maps android-inflate inflate-exception

5
推荐指数
1
解决办法
4647
查看次数

Android示例蓝牙聊天

我已经尝试过Android SDK的蓝牙聊天示例代码.代码没有错误,在设备上安装APK,打开蓝牙聊天时,强制关闭.

我用一个真实的设备进行调试,即Galaxy Nexus S.

请帮我 ..提前致谢.

android bluetooth forceclose

1
推荐指数
1
解决办法
7066
查看次数