在讨论论坛中从对象布尔中删除对象? [英] delete object from object bool in dissussion forum ?

查看:98
本文介绍了在讨论论坛中从对象布尔中删除对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有点不喜欢在c#中使用指针

我的代码被假定为读取了称为碟盘的对象

圆盘是发布对象的数组列表,
帖子有一个arraylist对象,每个对象都包含注释对象
[您可以想象这是Facebook页面]

假定deleteComment将从父帖子内的评论数组列表中删除评论(此)

简而言之,此代码无法正常工作,

hey all , im a lil bit confused with using pointers in c#

my code is assumed to read an object called disc-board

disc-board is arraylist of post objects ,
post has an object of arraylist , each of this contains comment object
[you can imagine this as facebook page]

the deleteComment is assumed to delete the comment (this) from the comment arraylist inside the parent post

simply , this code wont work ,

//DeleteCommentFromBool();
        int inarray = 0;
        ArrayList c = new ArrayList();
        ArrayList ar = (ArrayList)HttpContext.Current.Application["disc-board"];
        foreach (Post p in ar)
        {
            int i = ar.IndexOf(p);
            c = p.getComment();
            if (c.Contains(this))
            {
                inarray = c.IndexOf(this);
                c.RemoveAt(inarray);
                p.initializeComment();
                p.setcomment(c);
                ar.RemoveAt(i);
                ar.Insert(i, p);
                HttpContext.Current.Application["dis-board"] = ar;
                HttpContext.Current.Response.Redirect("post-board.aspx");
                break;
            }


有人可以告诉我这段代码有什么问题吗

没有错误,没有异常,但也没有结果


can any one tell me whats the wrong with this code

no error , no exceptions ,but aslo no results

推荐答案

您似乎在代码段末尾拼写了错误的"disc-board".这个:

You appear to have misspelled "disc-board" near the end of your code snippet. This:

HttpContext.Current.Application["dis-board"] = ar;



应该是这样的:



should be this:

HttpContext.Current.Application["disc-board"] = ar;


这篇关于在讨论论坛中从对象布尔中删除对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆