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

问题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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值