using 命名空间指令和cookie保存实体类的一些问题

来源:互联网 发布:微信时时彩源码 编辑:程序博客网 时间:2024/03/29 07:55
问题1:using 命名空间指令只能应用于命名空间的一些问题?
详细:
using 命名空间指令只能应用于命名空间;System.IO.StreamReader”是一个类型,而不是命名空间。。。如何解决啊(代码如下)
using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.IO.StreamReader;namespace WindowsFormsApplication2{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)        {            OpenFileDialog1.Filter = "文本文件(*.txt)*.txt";            if (openFileDialog1.ShowDialog() = DialogResult.OK)            {                try                {                    String line;                    StudentRecord.Clear();                    StreamReader sr = new StreaemReader(openFileDialog.FileName, System.Text.Encoding.Default);                    line = sr.ReadLine();                    StreamReader another = new StreamReader(@"d:\C#\1.txt");                    while (line != null)                    {                        String[] infos = new String[100];                        infos = line.Split('\0');                        StudenRecord.Add(new Student(infos[0], infos[1], infos[2], infos[3], infos[4], infos[5], infos[6], infos[7]));                        line=sr.ReadLine();                    }                    showInfo(StudentRccord);                    sr.Close();                }                catch (Exception ex)                {                MessageBox.Show("捕获异常:"+ex);                }            }        }    }}


回答:
只需要using System.IO; 这一句就可以了。
using System.IO.StreamReader;删除掉程序可以运行的。


问题2:如何实现cookie保存实体类信息到服务器?就是那个java的web项目中的两张表格在页面上传递实体类的信息。
回答:
当然可以。先encode成字符串,存进cookie,然后再decode成实体。
但这个方案有两个问题。
1. cookie一般很小。你存不了多少信息。
2. cookie安全性很差。
0 0
原创粉丝点击