我正在尝试在会话中保存数组并尝试将其恢复。以下是代码。但是当我调用 WebMethod 时出现以下错误。我正在使用c#。VS2010
错误:
System.NullReferenceException:未将对象引用设置为对象的实例。在 C:\Users\uydarp\Documents\Visual Studio 2010\Projects\xmlRW1\xmlRW1\Service1.asmx.cs 中的 xmlRW1.Service1.logic() 处:第 86 行
[WebMethod]
public int logic()
{
int[] myArray = { 1,2,3,4};
Session["MyArray"] = myArray;
int[] myArray2 = (int[])Session["MyArray"];
int firstElement = myArray2[0];
return firstElement;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用codeigniter为轮盘赌系统建立一个库.
我希望使代码非常高效和防黑客.
这是代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Prad Roulette
*
* Version: 0.1
*
* Author: Pradyummna Reddy
* prad@hireprad.co.uk
*
*
* Location: https://github.com/pradyummna/prad_roulette
*
* Created: 21/10/2014
*
* Description: The library can be used for roulette system developers
*
* Requirements: PHP5 or above
*
*/
class Prad_roulette
{
/**
*
* Function to find if the number is a valid roulette number
*
* @param …Run Code Online (Sandbox Code Playgroud)